Bootstrap FreeKB Articles

Ansible articles


Getting Started with Ansible Amazon Web Services (AWS) Getting Started with the Amazon Web Services (AWS) modules Amazon Web Services (AWS) Cloudwatch Create Amazon Web Services (AWS) Cloudwatch Alarm Amazon Web Services (AWS) Elastic Load Balancer (ELB) Create an Amazon Web Services (AWS) Elastic Load Balancer (ELB) Create an Amazon Web Services (AWS) Elastic Load Balancer (ELB) Target Group Amazon Web Services (AWS) Profile List Amazon Web Services (AWS) Profile Configurations Set Amazon Web Services (AWS) Profile Configurations Amazon Web Services (AWS) S3 Buckets List Amazon Web Services (AWS) S3 Buckets using the aws_s3_bucket_info module List files to Amazon Web Services (AWS) S3 Buckets using the s3_object module Upload files to Amazon Web Services (AWS) S3 Buckets using the s3_object module Amazon Web Services (AWS) Secrets Retrieve Amazon Web Services (AWS) Secret Value Amazon Web Services (AWS) Security Groups List Amazon Web Services (AWS) Security Groups using the ec2_security_group module Amazon Web Services (AWS) Virtual Private Cloud (VPC) Subnets List Amazon Web Services (AWS) VPC Subnets using the ec2_vpc_subnet_info module ansible command (ad-hoc task) ansible --version command ansible ad hoc copy command ansible ad hoc ping command ansible ad hoc setup command Getting Started with the ansible ad hoc command Ansible Galaxy Ansible Galaxy website ansible-galaxy info command ansible-galaxy init command ansible-galaxy install role (requirements) ansible-galaxy login command ansible-galaxy remove command ansible-galaxy search command ansible-galaxy version command Getting Started with Ansible Galaxy List role directories and installed roles using the ansible-galaxy list command Ansible Lint ansible-lint Ansible Vault --ask-vault-pass command line option --vault-id command line option --vault-password-file command line option Ansible Vault password file ansible-vault create command ansible-vault decrypt command ansible-vault edit command ansible-vault encrypt command ansible-vault encrypt_string command ansible-vault rekey command (change password) ansible-vault view command ANSIBLE_VAULT_PASSWORD_FILE environment variable Copy an ansible vault encrypted file to managed nodes Decrypting a vault encrypted file Get Ansible Vault password from a Hashicorp Vault Secret Get Ansible Vault password from an Amazon Web Services (AWS) Secrets Getting Started with Ansible Vault vault_password_file ansible.cfg ansible-doc command ansible ad hoc --args command ansible-doc become ansible-doc connection ansible-doc inventory ansible-doc modules ansible-doc shell ansible-doc strategy Getting Started with the ansible-doc command ansible-playbook command ansible-playbook --syntax-check flag ansible-playbook --version flag Getting Started with the ansible-playbook command Verbose Flags (-v -vv -vvv) Become ansible_become ansible_become_user ansible_become_pass variables (sudo) Become and --vault-password-file command line option become command line (--become --become-user --become-method --ask-become-pass --become-flags) become directives in ansible.cfg become parameter (sudo) Understanding Become Privilege Escalation Blocks Exception handling fatal errors using Block Rescue Always Getting Started with the block parameter CLI Getting Started with tower-cli Collections Create local collection Getting Started with Collections Install a collection using the ansible-galaxy collection install command List installed collections using the ansible-galaxy collection list command Dictionaries Append to a dictionary Convert a list in a dictionary to a string using the join filter Getting Started with Dictionaries (key value pairs) Update values in a dictionary Docker Create Docker container using the docker_container module Create Docker Volume using the docker_volume module Execute a command in a Docker container using the docker_container_exec module Get info on Docker container using the docker_container_info module Get info on Docker image using the docker_image_info module Log into docker.io Docker Hub using the docker_login module Manage Docker images using the docker_image module Manage Docker networks using the docker_network module Restart Docker container using the docker_container module Dry Run --check (dry run) command line flag Files Configuration file (ansible.cfg ansible-config) Filters Capitalize first character using the capitalize filter Convert a list into a string using the join filter Convert an integer, boolean, or AnsibleVaultEncryptedUnicode object into a string using the string filter Cut characters from a string using index numbers Decode a string using the b64decode filter Define a default value using the default filter Determine the type of value stored in a variable using the type_debug filter Encode a string using the b64encode filter Escape literal characters using regex_escape Escape special characters using urlencode Get directory name using the dirname filter Get file or directory name using the basename filter Getting Started with Filters Increment or Decrement an integer using the int filter Make a date human readable using the strftime filter regular expression regex_replace regular expression search using regex_findall regular expression search using regex_search Remove whitespace using trim Replace data in a string or variable using the replace filter Return an integer using the int filter Return the greatest value in array using the max filter Return the lowest value in array using the min filter Return the number of items in a variable or list using the length filter Round an integer up or down using the round filter Update a value to lower case using the lower filter Update a value to upper case using the upper filter Upper case first character using the title filter Importing Playbooks Roles and Tasks import_playbook module Importing tasks using import_tasks Including task in a playbook using the include_tasks module Install Install Ansible in a Python virtual environment Install Ansible on Linux using DNF Install Ansible on Linux using DNF or YUM Install Ansible on Linux using pip Install Ansible Tower on Linux Install ansible-lint on Linux using pip Uninstall Ansible on Linux using pip Uninstall Ansible Tower Inventory --list-hosts command line option ansible-inventory --graph command ansible-inventory --list command Defining your inventory Inventory in ansible.cfg Run tasks against certain managed nodes using the --limit option Run tasks against certain managed nodes using the -i or --inventory option Run tasks against certain managed nodes using the hosts parameter Run tasks against certain managed nodes using the when parameter Run tasks on the control node Inventory (static) Create your own inventory file Default hosts file Define hostname aliases in inventory using ansible_host Inventory file format (INI YAML) Inventory groups (all | ungrouped | other) Inventory Plugin advanced_host_list inventory plugin Cobbler dynamic inventory script constructed inventory plugin Getting Started with the Dynamic Inventory host_list inventory plugin ini inventory plugin nmap inventory plugin vmware_vm_inventory inventory plugin yaml inventory plugin IP Address Convert subnet mask into prefix using ansible.utils.ipaddr Determine if an IP address is valid in a Subnet using ansible.utils.ipaddr Determine Network Address using ansible.utils.ipaddr List all IP addresses using ansible_all_ipv4_addresses List all IP addresses using ansible_interfaces List default IP address using ansible_default_ipv4 Update Network Manager IP Addresses using the nmcli module Jinja2 Jinja2 templating JSON Getting Started parsing JSON Parse JSON using from_json Store JSON value in variable Library Understanding Ansible Library (modules directories) Lists Append elements to a List Combine or Merge a List using plus or zip Compare Differences between Lists Convert a string into an list using the list filter Convert a string into an list using the split filter Create a nested List Getting Started with Lists Remove duplicates from a list Remove elements from a List Return the first element in a list Return the last element in a list Sort a list or dictionary using the sort filter Logs Logging to a custom log file (log_path) Lookup Create variables on Ansible controller using lookup vars lookup env home (users home directory) lookup file (read local file) lookup pipe date (time) lookup pipe hostname (control node) lookup vars and nested variables whoami using lookup env user or ansible_user_id Loops Loop over a block of tasks Loop through a nested List Loop through a sequence of numbers using the with_sequence parameter Loop through JSON Loop through list using the loop parameter Loop through list using the with_indexed_items parameter Loop through list using the with_items parameter Loop through list using the with_list parameter Loop through list using vars Loop through nested list using the with_nested parameter loop_control loop_var (set custom item) Looping through a dictionary using with_dict Looping through a List Suppress output using no_log and loop_control until parameter (while loop) LVM (Logical Volume Manager) Extend an LVM logical volumes using the lvol module Manage LVM logical volumes using the lvol module Manage LVM volume groups using the lvg module Math Addition Division Multiplication Subtraction Meta Clearing fatal errors using meta clear_host_errors End a play for all hosts using meta end_play End a play for certain hosts using meta end_host Module Utilities module_utils Modules Add and commit a file to Git using the shell module Add repository using the yum_repository module Append or remove SSH public certificates from an authorized_keys file Append or Remove SSH servers keys to known hosts file Append user account to groups Append, change, or remove a block of lines in a file using the blockinfile module Append, change, or remove a line in a file using the lineinfile module Blank out a file using the command or shell module Change file owner group mode permissions using the file module Change hostname Change or remove a line in a file using the replace module Clone a repository using the git module Compare differences between files Copy a file or directory Copy remote files and directories using the synchronize module Create a compressed archive of a Git repository Create a compressed tar zip bzip2 gzip archive Create a directory using the file module Create a public certificate using the openssh_cert module Create a symbolic link using the file module Create an array of value using the set_fact module Create and modify access control list entries using the acl module Create and remove groups using the group module Create or remove a file using the file module Create or remove partition using the parted module Create or send email using the mail module Create public certificate and private key using the openssh_keypair module Create public certificate and private key using the user module Create user account Create variable, list or dictionary using set_fact curl module Determine if a file or directory exists using the stat module Determine if a remote file or directory exists using the uri module df module (disk filesystem usage ansible_mounts) Download files from a remote system using get_url End play using the fail module Ensure variable is defined using the assert module Extract a tar zip bzip2 gzip archive using the unarchive module Extract specific files in a tar zip bzip2 gzip archive using the unarchive module Gather facts using the setup module Gather service and systemd facts using service_facts Get index number of an element in a list using index_of Getting Started with Modules iptables module List files and directories using the find module List the files and directories in a tar zip bzip2 gzip archive using the unarchive module Manage firewalld Manage packages using the dnf module Mount and unmount volumes, shares, and partitions Move files and directories mysql_db module mysql_user module Partition file system using the filesystem module Pause or sleep in a playbook ping module pip module Print output to the console using the debug module Read file using the slurp module Reboot a system Remove a directory using the file module Remove files and directories using the file module Rename a file or directory Run a command on Windows hosts using the win_command module Run a command using the command module Run a command using the raw module Run a command using the shell module Run a script using the script module Save changes made to iptables using the iptables_state module SELinux module Set SELinux boolean using the seboolean module Set SELinux ports using the seport module start stop restart enable disable systemd services start stop restart services Submit a GET request to a REST API using the uri module Submit a POST request to a REST API using the uri module uninstall delete remove package using the yum module Update a users cron table Windows ping module (win_ping) Write to a local file using the shell module Nested Variables Getting Started with Nested Variables Updating nested variables Network Manager (nmcli) Modify Network Manager using the nmcli module Order Control the order of managed nodes inventory Packages List packages using package_facts List packages using the yum module Manage packages using the package module Manage packages using the yum module Parameters changed_when parameter check_mode parameter (dry run) Continue playbook execution when a task gets a fatal return code using the failed_when paramater Control long running task timeout with async and poll Determine if a directory is empty Determine if a file or directory is readable or writeable or executable using stat group parameter Ignore errors using the ignore_errors paramater local_action parameter mode parameter module_defaults parameter no_log parameter (mask suppress output) owner parameter recurse parameter remote_src parameter Retry a task using the retries parameter Retry a task with a delay using the delay parameter Run task on specific server using delegate_to run_once parameter selevel parameter (SELinux) serole parameter (SELinux) setype parameter (SELinux) seuser parameter (SELinux) Store output JSON in variable using the register parameter Target servers using the hosts parameter validate parameter warnings parameter (warn: true, warn: false) when file or directory exists or does not exist when object is or is not a directory (out.stat.isdir) when parameter (if else statement) when variable is defined or not defined when variable is empty or not empty playbooks Getting Started with playbooks Plugins Run tasks at end of pre_tasks, tasks, post_tasks using handlers and notify Python ansible command python version Setting Python version using ansible_python_interpreter Setting Python version using the interpreter_python directive in ansible.cfg Retry Retry file Roles Define roles path directories using the ANSIBLE_ROLES_PATH variable Define roles path directories using the roles_path directive in ansible.cfg Download role using the git clone command Getting Started with Roles Install roles from RHEL system roles (rhel-system-roles) Invoking a role more than once using allow_duplicates Invoking a role using the include_role module Invoking preliminary tasks using pre_tasks Invoking tasks after roles using post_tasks Passing variables into a Role Role Dependencies Role Files Role Template Files (edit a file j2) Security Securing passwords with Ansible Special Variables / Connection Variables Getting Starting with the Connection Plugin Special Variables / Facts ansible_date_time fact ansible_distribution fact ansible_distribution_major_version fact ansible_distribution_release fact ansible_distribution_version fact ansible_hostname fact ansible_lvm fact ansible_user_id fact Getting Started with Facts (gather_facts) Special Variables / Magic Variables ansible_play_batch variable ansible_play_hosts magic variable ansible_play_hosts_all magic variable Get Kernel version using the ansible_kernel fact Get playbook directory using the playbook_dir variable Getting Started with Magic Variables inventory_hostname magic variable inventory_hostname_short magic variable List target servers passed into the --limit option using ansible_limit play_hosts magic variable SSH --ask-pass (SSH) command line flag --connection command line flag --user command line option (SSH) ansible_user ansible_ssh_pass in /etc/ansible/hosts ansible_user ansible_ssh_pass in group_vars Getting Started with SSH remote_user parameter (SSH) Using an encrypted password with SSH and group_vars Using an encrypted password with SSH and vars_files Tags Getting Started with Tags Task Execution (Parallelism) --list-tasks command line option (Parallelism) Complete each task on each node before moving onto next task using Debug Strategy (Parallelism) Complete each task on each node before moving onto next task using Linear Strategy (Parallelism) Getting Started with Task Execution (Parallelism) Limit the number of hosts that will execute the tasks in a playbook simultaneously using Host Pinned Strategy (Parallelism) Limit the number of workers using Throttle (Parallelism) Nodes process tasks independently using Free Strategy (Parallelism) Set the number of nodes a task will run against simultaneously using Forks (Parallelism) Set the number of nodes a task will run against simultaneously using forks in ansible.cfg (Parallelism) Set the number of nodes a task will run against simultaneously using --forks command line option (Parallelism) Set the number of target servers that tasks will run against simultaneously using serial TBD Run Ansible against Windows hosts Terminology idempotent Tower Add managed hosts to static inventory in Tower Create Job Schedule in Tower Create Job Template in Tower Create Machine Credentials in Tower Create Project in Tower Create static Inventory in Tower Create Vault Credentials in Tower Delete Job Template in Tower Delete Project in Tower Delete static Inventory in Tower Extra Variables in Tower Get latest SCM revision Getting Started with Tower Prompt for user input using Surveys in Tower Remove managed hosts to static inventory in Tower Start Job Template in Tower Start Stop Restart Ansible Tower Viewing Completed Jobs Troubleshooting Resolve "AnsibleVaultEncryptedUnicode object has no attribute split" Resolve "Attempting to decrypt but no vault secrets found" Resolve "basic: the specified credentials were rejected by the server" Resolve "boto3 required for this module" Resolve "Connection refused" with Windows Host Resolve "couldn't resolve module" Resolve "DEPRECATION WARNING bare variable" Resolve "Destination not writable" Resolve "Distribution should use /usr/bin/python3, but is using /usr/bin/python" Resolve "Encountered unknown tag" Resolve "Error reading config file (ansible.cfg): File contains no section headers" Resolve "Error while fetching server API version" Resolve "ERROR! Error when finding available api versions from default (https://galaxy.ansible.com) (HTTP Code: 403, Message: Forbidden)" Resolve "Failed to import the required Python library" Resolve "Failed to parse foo.yml with foo plugin" Resolve "global flags not at the start of the expression" Resolve "got an unexpected keyword argument 'workdir'" Resolve "Job terminated due to timeout" in Ansible Tower Resolve "module not found" Resolve "non-zero return code" Resolve "playbook hangs at Gathering Facts" Resolve "rmtree failed: [Errno 13] Permission denied" Resolve "The ipaddr filter requires python's netaddr be installed on the ansible controller" Resolve "The loop variable 'item' is already in use" Resolve "The Python 2 bindings for rpm are needed for this module" Resolve "There was an issue creating as requested: [Errno 13] Permission denied" Resolve "unable to connect to database, check login_user and login_password are correct or /root/.my.cnf has the credentials" Resolve "unknown url type" Resolve "unreachable could not resolve hostname name or service not known" Resolve "UNREACHABLE failed to connect to the host via ssh permission denied" Resolve "urlopen error timed out" Resolve "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this" Resolve "winrm or requests is not installed: No module named winrm" Variables ANSIBLE_DEBUG variable Appending values to a variable using set_fact Create nested variables using the vars plugin Create null variables Create variables for groups of nodes using group_vars Create variables in /etc/ansible/hosts or your own inventory file Create variables on the command line using the -e or --extra-vars option Create variables on the command line using vars_prompt Create variables, lists and dictionaries using vars Delegate variable from host A to host B Delegating facts variables list dictionaries using hostvars Get variables from a file using include_vars Get variables from a file using vars_files Getting Started with variables YAML Edit YAML file using kwoodson.yedit Parse YAML using from_yaml Parse YAML using to_yaml or to_nice_yaml Remove keys from a YAML file using ansible.utils.remove_keys Retain keys from a YAML file using ansible.utils.keep_keys