FreeKB - Ansible articles
Ansible articles

Getting Started with AnsibleResolve "The Python 2 bindings for rpm are needed for this module"ansible-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.cfgArraysGetting Started with Arrays Dictionary ListsAppend values to an Array Dictionary ListCombine or Merge an Array Dictionary ListCreate a nested Array Dictionary ListLoop through a nested Array Dictionary ListLooping through an Array Dictionary ListBecomeansible_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 parameterCollectionsGetting Started with CollectionsInstall a collection using the ansible-galaxy collection install commandDry Run--check (dry run) command line flagFilesConfiguration file (ansible.cfg ansible-config)FiltersGetting Started with FiltersCapitalize first character using the capitalize filterCollapse array to variable using the join filterConvert an integer, boolean, or AnsibleVaultEncryptedUnicode object into a string using the string filterCut a string into pieces using the split 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 filterGet 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 filterregex_escaperegex_replaceregex_searchregular expression search using regex_findall Remove whitespace using the trim filterReplace data in a string or variable using the replace filterReturn an integer using the int filterReturn the first value in an array using the first filterReturn the greatest value in array using the max filterReturn the last value in an array using the last filterReturn the lowest value in array using the min filterReturn the number of items in a variable or array 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 filterHashesGetting Started with Hashes (key value pairs)Looping through an HashUpdated hash valueInstallInstall Ansible on Linux using DNFInstall Ansible on Linux using pipInstall Ansible on Linux using YUMInstall 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 JSON arrayStore JSON value in variableLibraryUnderstanding Ansible Library (modules directories)LogsGetting Started with Logs (log_path)Lookuplookup env home (users home directory)lookup file (read local file)lookup pipe date (time)lookup pipe hostname (control node)lookup varslookup 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 an SSH servers public certificates to a known_hosts fileAppend or remove SSH public certificates from an authorized_keys 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 or array using the set_fact modulecurl 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_ofIncluding task in a playbook using the include_tasks moduleinstall update packages using the yum moduleiptables moduleList available installed packages using the yum moduleList files and directories using the find 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 using the command moduleRun a command using the raw moduleRun a command using the shell moduleRun a scriptSave 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 servicesuninstall delete remove package using the yum moduleUpdate a users cron tableWrite 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 polldelegate_to parameter (run task on specific server)Determine if a directory is emptygroup parameter hosts parameterIgnore 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_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_once parameterselevel parameter (SELinux)serole parameter (SELinux)setype parameter (SELinux)seuser parameter (SELinux)Store output JSON in variable using the register 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 playbooksPluginsHandlers Notify Pluginimport_playbook modulePythonansible 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 tasks after roles using post_tasksInvoking tasks before roles using pre_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 variableinventory_hostname magic variableinventory_hostname_short magic variableplaybook_dir 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)TerminologyidempotentTowerGetting 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 "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 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 "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"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, arrays, lists using the vars pluginDelegate variable from host A to host BGet fact of managed node using hostvarsGet variables from a file using include_varsGet variables from a file using vars_files

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |