Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Ansible

Precondition:

Let's say ansible project has similary structure:

foo_project/
  ansible.cfg
  roles/
    role_01/
      tasks/
        main.yml
      defaults/
        main.yml
  inventories/
    host_vars/
      any_host
    group_vars/
      any_group
    production

Examples:

Run any shell command on host_group

$ ansible <host_group> -m shell -a 'uptime' -vv

Escape go template {{ }} symbols

# Example 01
consul_bind_addr:  "{{ '{{ GetInterfaceIP \\\"eth0\\\" }}' }}"
consul_advertise_addr:  "{{ '{{ GetInterfaceIP \\\"eth1\\\" }}' }}"

# Example 02
UsernameTemplate: "{{ '{{ username }}' }}"

Usefull tips

--diff - for check differens
--check - just dry-run