/ansible-examples

Examples of Ansible.

BSD 2-Clause "Simplified" LicenseBSD-2-Clause

Ansible examples

Various examples of Ansible code.

(This file is generated. Do not update it manually. See the section below.)

Index

Ansible filter

  • ansible.netcommon.ipaddr 254,
  • ansible.utils.hwaddr 197,
  • ansible.utils.keep_keys 289,
  • ansible.utils.remove_keys 289,
  • ansible.utils.replace_keys 289,
  • cartesian 156,
  • combine 111,
  • community.general.dict_kv 281,
  • community.general.groupby_as_dict 282,
  • community.general.jc 284,
  • community.general.lists_mergeby 286,
  • community.general.path_join 285,
  • community.general.version_sort 283,
  • d() 245,
  • default 245, 257,
  • default() 245,
  • default(omit) 257,
  • dict2items 103,
  • difference 98,
  • extract 174,
  • flatten 119,
  • from_yaml 26, 173,
  • from_yaml_all 173,
  • hwaddr 197,
  • intersect 159,
  • ipaddr 254,
  • json_query 2, 20, 43, 69, 267,
  • json_query filter contains 43, 69,
  • json_query function merge 290,
  • json_query functions 140,
  • json_query issue to_yaml|from_yaml 267,
  • password_hash 76,
  • product 156,
  • quote 183,
  • regex_replace 135,
  • shuffle 202,
  • splitext 192,
  • strftime 217,
  • ternary 180,
  • to_datetime 217,
  • to_nice_json 26,
  • to_yaml 173,
  • union 112,
  • zip 56,

Ansible keyword

Ansible plugins

  • Connection 218,

Ansible test

Basics

  • always 52,
  • async 87,
  • Asynchronous actions and polling 87,
  • block 52,
  • Boolean 151,
  • Callback 150,
  • Compare dictionaries 253,
  • Expansion of expressions 149,
  • Expansion of variables 139,
  • falsy 272,
  • Fibonacci 70,
  • Filters 32,
  • Handlers 93,
  • Inventory 80,
  • Jinja2 204,
  • Lazy evaluation 131,
  • lookup plugins 39,
  • Loop 176,
  • MySQL command 61,
  • NFS 227,
  • Passwords 34,
  • Python 248,
  • Quotation 101,
  • requirements.yml 232,
  • rescue 52,
  • Role meta platforms 225,
  • Roles 141, 178,
  • run_once 46,
  • Strings and Lists 38,
  • Test include_role, import_role, and tags 124,
  • Testing paths 185,
  • truthy 272,
  • vars 136, 178,
  • Vault 53,
  • Workflow 133,
  • Xen 44,
  • ZFS 42,

Boolean

  • and, or, xor 67,

Cache

  • cache plugin 181,
  • fact_caching = jsonfile 57,
  • jsonfile cache plugin 181,

Callback

  • community.general.log_plays 250,
  • log_plays 250,

Collection

  • F5 modules 81,
  • gcp 144,

Conditions

  • when 96,

Config

  • action_warnings 115,
  • ANSIBLE_ACTION_WARNINGS 115,
  • ANSIBLE_CACHE_PLUGIN 261,
  • ANSIBLE_COLOR_* 208,
  • ANSIBLE_HASH_BEHAVIOUR 143,
  • ANSIBLE_KEEP_REMOTE_FILES 222,
  • ansible_python_interpreter 155, 155,
  • ansible_remote_tmp 223,
  • ANSIBLE_REMOTE_TMP, ANSIBLE_REMOTE_TEMP 223,
  • ANSIBLE_REMOTE_USER 205,
  • colors section 208,
  • conditional_bare_variables 182,
  • CONDITIONAL_BARE_VARS 182,
  • DEFAULT_JINJA2_NATIVE 260,
  • filter_plugins 85,
  • hash_behaviour 143,
  • remote_tmp 223,
  • remote_user 205,

Custom filter

  • combine_lossless 262,
  • dict_flatten 138,
  • dict_utils 138,
  • mac-vendor-lookup 292,
  • netaddr_iter_iprange 254,

Custom module

  • Python subprocess.run 163,

Data structure

Delegation

  • delegate_facts 186,
  • local_action 83,

Deprecated

  • warning 29,

Devel

  • Custom modules 256,
  • Development of a module 279,
  • filter_core 291,
  • Job management (async, async_status, kill, logger, cache) 287,
  • Role UBUNTU20-CIS 293,
  • Supports_check_mode and changed 279,
  • vbotka.ansible.community.general filter any2items 237,

Dictionary

  • Create, update, combine 207,
  • Iterate dictionary in play 3,
  • Iterate dictionary in template 1,
  • Select items from dictionary 12,

Handlers

Import

  • import_playbook 15,

Include

  • Galaxy role vbotka.ansible_lib 65, 66,
  • include_role 18, 24, 65,
  • include_vars 24, 66,

Indentation

  • Test indentation of a block 13,

Inventory

  • Dynamic inventory 125,
  • hosts 86,

Jinja

  • Jinja template formatting 236,
  • Jinja tests 265,
  • loop.index 295,
  • lstrip_blocks 100,
  • trim_blocks 100,
  • white-space control 100,

Jinja filter

Jinja function

Jinja template

  • ansible_managed 278,
  • extends 194,
  • if then else 191,
  • set 73,
  • template 75,

List

  • Add item to list 99,
  • Managing lists 247,

Lookup

  • ansible.builtin.indexed_items 170,
  • ansible.utils.to_paths 280,
  • community.general.dig 169,
  • dig 169,
  • env 116,
  • file 210,
  • fileglob 106,
  • first_found 120,
  • inventory_hostnames 271,
  • password 145,
  • pipe 184,
  • subelements 40,
  • to_paths 280,
  • with_indexed_items 170,

Loop

  • extended 220,
  • Extended loop variables 220,
  • include_tasks 241,
  • index_var 6,
  • Iterate blockinfile from templates 45,
  • loop include_tasks 8,
  • loop include_tasks and delegate_to 14,
  • loop_control 6, 220,
  • Nested loops 54,
  • run_once 241,
  • with_items vs. loop 243,
  • with_lines 95,
  • with_sequence 6,
  • with_together zip 63,

Math

  • Arithmetic 55,
  • compare integers 263,
  • Jinja math 10,

Module

  • add_host 134,
  • ansible.builtin.add_host 134,
  • ansible.builtin.assert 239,
  • ansible.builtin.async_status 5,
  • ansible.builtin.blockinfile 123,
  • ansible.builtin.command 30, 35, 171,
  • ansible.builtin.copy 94,
  • ansible.builtin.cron 231,
  • ansible.builtin.debug 168,
  • ansible.builtin.expect 72,
  • ansible.builtin.fail 90,
  • ansible.builtin.fetch 203,
  • ansible.builtin.file 130,
  • ansible.builtin.find 37,
  • ansible.builtin.getent 48,
  • ansible.builtin.group_by 108,
  • ansible.builtin.include_tasks 190,
  • ansible.builtin.include_vars 142,
  • ansible.builtin.lineinfile 84,
  • ansible.builtin.meta 154,
  • ansible.builtin.package 198,
  • ansible.builtin.package_facts 121,
  • ansible.builtin.ping 226,
  • ansible.builtin.raw 137,
  • ansible.builtin.replace 77,
  • ansible.builtin.script 128,
  • ansible.builtin.set_fact 22, 167,
  • ansible.builtin.set_stats 58,
  • ansible.builtin.setup 212,
  • ansible.builtin.shell 128, 172,
  • ansible.builtin.slurp 235,
  • ansible.builtin.stat 127,
  • ansible.builtin.tempfile 189,
  • ansible.builtin.unarchive 78,
  • ansible.builtin.uri 51,
  • ansible.builtin.user 11,
  • ansible.builtin.wait_for 110,
  • ansible.builtin.wait_for_connection 209,
  • ansible.builtin.yum 107,
  • ansible.netcommon.net_ping 226,
  • ansible.posix.synchronize 7,
  • ansible.posix.sysctl 238,
  • assert 239,
  • async_status 5,
  • blockinfile 123,
  • cisco.ios.ios_ping 226,
  • cli_parse 274,
  • command 30, 35, 171, 172,
  • community.crypto.openssl_* 228,
  • community.crypto.x509_certificate 242,
  • community.general.cronvar 231,
  • community.general.dconf 92,
  • community.general.ini_file 102,
  • community.general.mail 193,
  • community.general.parted 25,
  • community.general.read_csv 153,
  • community.general.snmp_facts 152,
  • community.general.xml 199,
  • copy 94,
  • creates 35,
  • cron 231,
  • csv 153,
  • dconf 92,
  • debug 168,
  • expect 72,
  • fail 90,
  • fetch 203,
  • file 130,
  • find 37,
  • flush_handlers 288,
  • get_url 273,
  • getent 48,
  • group_by 108,
  • import_role 124,
  • include_role 124,
  • include_tasks 190,
  • include_vars 142,
  • ini_file 102,
  • ios_ping 226,
  • lineinfile 84, 277,
  • mail 193,
  • meta 154, 288,
  • net_ping 226,
  • openssl_* 228,
  • package 198,
  • package_facts 121,
  • ping 226,
  • raw 137,
  • read_csv 153,
  • replace 77,
  • script 128,
  • set_fact 22, 167,
  • set_stats 58,
  • setup 212,
  • shell 128, 172,
  • slurp 235,
  • snmp_facts 152,
  • stat 127,
  • synchronize 7,
  • sysctl 238,
  • tempfile 189,
  • unarchive 78,
  • uri 51,
  • user 11,
  • wait_for 110,
  • wait_for_connection 209,
  • xml 199,
  • yum 107,

Parameter

  • check ansible-playbook parameter, ansible_check_mode 213,
  • limit 132,
  • validate 164,

Playbook

  • Run the playbook only on one host per group 47,

Python method

Recursion

  • Referencing other dict keys in the same parent dict is not supported 129,

Role

  • al_bsd_service_facts 270,
  • CIS role UBUNTU20-CIS 293,
  • Galaxy role vbotka.ansible_lib 270,
  • Galaxy role vbotka.config_light 148,
  • Role defaults 266,

Setup

  • ansible.builtin.setup 9,
  • ansible_interfaces 252,
  • ansible_mounts 249,
  • gather_facts 9,
  • service_facts 9,

Special variables

  • ansible_play_batch 255,
  • ansible_play_hosts 255,
  • ansible_play_hosts_all 255,
  • group_names 175,
  • groups 113,

Strategy plugin

  • host_pinned 221,

String

  • Concatenate strings 246,
  • match 79,
  • regex 79,
  • search 79,
  • string manipulation 200,
  • testing strings 79,

Syntax

  • Python null 224,
  • YAML None 224,

Tags

  • block tags 264,
  • import_playbook and tags 19,
  • variable in tags 269,

Test

  • boolean 294,
  • bulk-set task arguments 89,
  • Galaxy role vbotka.linux_lib 91,
  • is all 296,
  • items2dict2 114,
  • iterable 294,
  • mapping 294,
  • race conditions 258,
  • sequence 294,
  • string 294,

Tools

  • Debug tools 31,

Utility

  • ansible-inventory 27,
  • ansible-pull 233,
  • ansible-runner 126,
  • jq 60,
  • passwordstore 234,

Vars

  • ansible_facts 165,
  • facts.d 177,
  • group_vars 71,
  • host_vars 28,
  • hostvars 216,
  • Precedence of the variables 33,
  • Scope of variables 158,
  • Special variables 17,
  • Substitution 188,
  • Test names in a block 23,
  • vars_prompt, pause 36,

vbotka.ansible_lib

  • al_bsd_service_facts 270,

Contents

Update README.md

To update README.md file go to the directory doc.

  • Update the file list_of_examples.yml if you want to update the list of examples in the contents and tags in the index. The structure of a line in this file is follows. If the example belongs to more categories add more lines wiht he same number of the example. The comment is optional.
     - Number_of_the_example. "Category; tag; tag; ... tag; Comment."
  • Update the template templates/README.md.j2 if you want to update the text.

  • Just type make to update README.md

     shell> ./make

License

license

Author Information

Vladimir Botka