FreeKB - Ansible articles
Ansible articles

Getting Started with Ansibleansible-doc commandGetting Started with the ansible-doc commandansible ad hoc --args commandansible-doc becomeansible-doc connectionansible-doc inventoryansible-doc modulesansible-doc shellansible-doc strategyansible-playbook commandGetting Started with the ansible-playbook commandansible-playbook --syntax-check flagansible-playbook --version flagVerbose Flags (-v -vv -vvv)ansible command (ad-hoc task)Getting Started with the ansible ad hoc commandansible --version commandansible ad hoc copy commandansible ad hoc ping commandansible ad hoc setup commandAnsible GalaxyGetting Started with Ansible GalaxyAnsible Galaxy websiteansible-galaxy info commandansible-galaxy init commandansible-galaxy install role (requirements)ansible-galaxy login commandansible-galaxy remove commandansible-galaxy search commandansible-galaxy version commandList role directories and installed roles using the ansible-galaxy list commandAnsible Lintansible-lintAnsible VaultGetting Started with Ansible Vault--ask-vault-pass command line option--vault-id command line option--vault-password-file command line optionAnsible Vault password fileansible-vault create commandansible-vault decrypt commandansible-vault edit commandansible-vault encrypt command ansible-vault encrypt_string commandansible-vault rekey command (change password)ansible-vault view commandANSIBLE_VAULT_PASSWORD_FILE environment variableCopy an ansible vault encrypted file to managed nodesDecrypting a vault encrypted filevault_password_file ansible.cfgBecomeansible_become ansible_become_user ansible_become_pass variables (sudo)Become and --vault-password-file command line optionbecome command line (--become --become-user --become-method --ask-become-pass --become-flags)become directives in ansible.cfgbecome parameter (sudo)Understanding Become Privilege EscalationBlocksGetting Started with the block parameterException handling fatal errors using Block Rescue AlwaysCLIGetting Started with tower-cliCollectionsGetting Started with CollectionsInstall a collection using the ansible-galaxy collection install commandDictionariesGetting Started with Dictionaries (key value pairs)Append to a dictionary Convert a list in a dictionary to a string using the join filterLooping through a dictionary using with_dictUpdate values in a dictionary Dry Run--check (dry run) command line flagFilesConfiguration file (ansible.cfg ansible-config)FiltersGetting Started with FiltersCapitalize first character using the capitalize filterConvert a list into a string using the join filterConvert a string into an list using the list filterConvert an integer, boolean, or AnsibleVaultEncryptedUnicode object into a string using the string filterCut characters from a string using index numbersDecode a string using the b64decode filterDefine a default value using the default filterDetermine if IP address is properly formatted using the ipaddr filterDetermine the type of value stored in a variable using the type_debug filterEncode a string using the b64encode filterEscape literal characters using regex_escapeEscape special characters using urlencodeGet directory name using the dirname filterGet file or directory name using the basename filterIncrement or Decrement an integer using the int filterMake a date human readable using the strftime filterregular expression regex_replaceregular expression search using regex_findall regular expression search using regex_searchRemove whitespace using trimReplace data in a string or variable using the replace filterReturn an integer using the int filterReturn the first element in a list using the first filterReturn the greatest value in array using the max filterReturn the last element in a list using the last filterReturn the lowest value in array using the min filterReturn the number of items in a variable or list using the length filterRound an integer up or down using the round filterSort an array using the sort filterUpdate a value to lower case using the lower filterUpdate a value to upper case using the upper filteUpper case first character using the title filterImporting Playbooks Roles and TasksImporting tasks using import_tasksimport_playbook moduleIncluding task in a playbook using the include_tasks moduleInstallInstall Ansible in a Python virtual environment using PIPInstall Ansible on Linux using DNFInstall Ansible on Linux using DNF or YUMInstall Ansible on Linux using pipInstall Ansible Tower on LinuxInstall ansible-lint on Linux using pipUninstall Ansible on Linux using pipUninstall Ansible TowerInventory--list-hosts command line optionansible-inventory --graph commandansible-inventory --list commandDefining your inventoryRun tasks against certain managed nodes using the --limit optionRun tasks against certain managed nodes using the -i or --inventory optionRun tasks against certain managed nodes using the hosts parameterRun tasks against certain managed nodes using the when parameterRun tasks on the control nodeInventory (dynamic)Getting Started with the Dynamic Inventoryadvanced_host_list dynamic inventory pluginCobbler dynamic inventory scripthost_list dynamic inventory pluginini dynamic inventory pluginnmap dynamic inventory pluginvmware_vm_inventory dynamic inventory pluginyaml dynamic inventory pluginInventory (static)Create your own inventory fileDefault hosts fileDefine hostname aliases in inventory using ansible_hostInventory file format (INI YAML)Inventory groups (all | ungrouped | other)Jinja2Jinja2 templatingJSONGetting Started parsing JSONLoop through JSONStore JSON value in variableLibraryUnderstanding Ansible Library (modules directories)ListsGetting Started with ListsAppend elements to a ListCombine or Merge a List using plus or zipConvert a string into an list using the split filterCreate a nested ListLoop through a nested ListLooping through a ListRemove elements from a ListLogsLogging to a custom log file (log_path)LookupCreate variables on Ansible controller using lookup varslookup env home (users home directory)lookup file (read local file)lookup pipe date (time)lookup pipe hostname (control node)lookup vars and nested variableswhoami using lookup env user or ansible_user_idMetameta clear_host_errors (continue fail fatal)Stop halt or exit a playbook using meta end_playModulesGetting Started with ModulesAdd and commit a file to Git using the shell moduleAdd repository using the yum_repository moduleAppend or remove SSH public certificates from an authorized_keys fileAppend or Remove SSH servers keys to known hosts fileAppend user account to groupsAppend, change, or remove a block of lines in a file using the blockinfile moduleAppend, change, or remove a line in a file using the lineinfile moduleBlank out a file using the command or shell moduleCease execution using the fail moduleChange file owner group mode permissions using the file moduleChange hostnameChange or remove a line in a file using the replace moduleClone a repository using the git moduleCopy a file or directoryCopy remote files and directories using the synchronize moduleCreate a compressed archive of a Git repositoryCreate a compressed tar zip bzip2 gzip archiveCreate a directory using the file moduleCreate a public certificate using the openssh_cert moduleCreate a symbolic link using the file moduleCreate an array of value using the set_fact moduleCreate and modify access control list entries using the acl moduleCreate and remove groups using the group moduleCreate Docker container using the docker_container moduleCreate or remove a file using the file moduleCreate or remove partition using the parted moduleCreate or send email using the mail moduleCreate public certificate and private key using the openssh_keypair moduleCreate public certificate and private key using the user moduleCreate user accountCreate variable, list or dictionary using set_factcurl moduleDetermine if a file or directory exists using the stat moduleDetermine if a remote file or directory exists using the uri moduledf module (disk filesystem usage ansible_mounts)diff moduleDownload files from a remote system using get_urlEnsure variable is defined using the assert moduleExecute a command in a Docker container using the docker_container_exec moduleExtract a tar zip bzip2 gzip archive using the unarchive moduleGather facts using the setup moduleGet index number of an element in a list using index_ofGet info on Docker container using the docker_container_info moduleinstall update packages using the yum moduleiptables moduleList available installed packages using the yum moduleList files and directories using the find moduleLog into docker.io Docker Hub using the docker_login moduleManage Docker images using the docker_image moduleManage Docker networks using the docker_network moduleManage firewalldManage LVM logical volumes using the lvol moduleManage LVM volume groups using the lvg moduleManage packages using the df moduleManage packages using the package moduleMount and unmount partition in /etc/fstabMove files and directoriesmysql_db modulemysql_user modulePartition file system using the filesystem modulePause or sleep in a playbookping modulepip modulePrint output to the console using the debug moduleRead file using the slurp moduleReboot a systemRemove a directory using the file moduleRemove files and directories using the file moduleRename a file or directoryRun a command on Windows hosts using the win_command moduleRun a command using the command moduleRun a command using the raw moduleRun a command using the shell moduleRun a script using the script moduleSave changes made to iptables using the iptables_state moduleSELinux moduleSet SELinux boolean using the seboolean moduleSet SELinux ports using the seport modulestart stop restart enable disable systemd servicesstart stop restart servicesSubmit a GET request to a REST API using the uri moduleSubmit a POST request to a REST API using the uri moduleuninstall delete remove package using the yum moduleUpdate a users cron tableWindows ping module (win_ping)Write to a local file using the shell moduleModule Utilitiesmodule_utilsNested VariablesGetting Started with Nested VariablesUpdating nested variablesOrderControl the order of managed nodes inventoryParameterschanged_when parameter check_mode parameter (dry run)Continue playbook execution when a task gets a fatal return code using the failed_when paramaterControl long running task timeout with async and pollDetermine if a directory is emptygroup parameter Ignore errors using the ignore_errors paramaterlocal_action parameterLoop through a sequence of numbers using the with_sequence parameterLoop through list using the loop parameterLoop through list using the with_indexed_items parameterLoop through list using the with_items parameterLoop through list using the with_list parameterLoop through list using varsLoop through nested list using the with_nested parameterloop_control loop_var (set custom item)mode parameter module_defaults parameterno_log and loop_control parameters (suppress output)no_log parameter (mask suppress output)owner parameter recurse parameterremote_src parameterRetry a task using the retries parameter Retry a task with a delay using the delay parameterRun task on specific server using delegate_torun_once parameterselevel parameter (SELinux)serole parameter (SELinux)setype parameter (SELinux)seuser parameter (SELinux)Store output JSON in variable using the register parameterTarget servers using the hosts parameteruntil parameter (while loop)validate parameterwarnings parameter (warn: true, warn: false)when file or directory exists or does not existwhen file or directory is writeable (out.stat.writeable)when object is or is not a directory (out.stat.isdir)when parameter (if else statement)when variable is defined or not definedwhen variable is empty or not emptyplaybooksGetting Started with playbooksPluginsRun tasks at end of pre_tasks, tasks, post_tasks using handlers and notifyPythonansible command python versionansible_python_interpreter factRetryRetry fileRolesGetting Started with Roles Define roles path directories using the roles_path directive in ansible.cfgDefine roles path directories using the ANSIBLE_ROLES_PATH variableDownload role using the git clone commandInstall roles from RHEL system roles (rhel-system-roles)Invoking a role more than once using allow_duplicatesInvoking a role using the include_role moduleInvoking preliminary tasks using pre_tasksInvoking tasks after roles using post_tasksPassing variables into a RoleRole DependenciesRole FilesRole Template Files (edit a file j2)SecuritySecuring passwords with AnsibleSpecial Variables / Connection VariablesGetting Starting with the Connection PluginSpecial Variables / FactsGetting Started with Facts (gather_facts)ansible_all_ipv4_addresses factansible_date_time factansible_default_ipv4 factansible_distribution factansible_distribution_major_version factansible_distribution_version factansible_hostname factansible_lvm factansible_user_id factSpecial Variables / Magic VariablesGetting Started with Magic Variablesansible_all_ipv4_addresses magic variableansible_default_ipv4.address magic variableansible_limit magic variableansible_play_batch magic variableansible_play_hosts magic variableansible_play_hosts_all magic variableGet playbook directory using playbook_dir magic variableinventory_hostname magic variableinventory_hostname_short magic variableplay_hosts magic variableSSHGetting Started with SSH--ask-pass (SSH) command line flag--connection command line flag--user command line option (SSH)ansible_user ansible_ssh_pass in /etc/ansible/hostsansible_user ansible_ssh_pass in group_varsremote_user parameter (SSH)Using an encrypted password with SSHTagsGetting Started with TagsTask Execution (Parallelism)Getting Started with 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)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 nodes that tasks will run against simultaneously using serial (Parallelism)TBDRun Ansible against Windows hostsTerminologyidempotentTowerGetting Started with TowerAdd managed hosts to static inventory in TowerCreate Job Schedule in TowerCreate Job Template in TowerCreate Machine Credentials in TowerCreate Project in TowerCreate static Inventory in TowerCreate Vault Credentials in TowerDelete Job Template in TowerDelete Project in TowerDelete static Inventory in TowerExtra Variables in TowerGet latest SCM revisionPrompt for user input using Surveys in TowerRemove managed hosts to static inventory in TowerStart Job Template in TowerStart Stop Restart Ansible TowerViewing Completed JobsTroubleshootingResolve "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 "Connection refused" with Windows HostResolve "couldn't resolve module"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 "Failed to import the required Python library"Resolve "Failed to parse foo.yml with foo plugin"Resolve "got an unexpected keyword argument 'workdir'"Resolve "Job terminated due to timeout" in Ansible TowerResolve "module not found"Resolve "non-zero return code"Resolve "playbook hangs at Gathering Facts"Resolve "rmtree failed: [Errno 13] Permission denied"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 "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"VariablesGetting Started with variablesANSIBLE_DEBUG variableAppending values to a variable using set_factCreate nested variables using the vars pluginCreate null variablesCreate variables for groups of nodes using group_varsCreate variables in /etc/ansible/hosts or your own inventory fileCreate variables on the command line using the -e or --extra-vars optionCreate variables on the command line using vars_promptCreate variables, lists and dictionaries using varsDelegate variable from host A to host BDelegating facts variables list dictionaries using hostvarsGet variables from a file using include_varsGet variables from a file using vars_files