Home / Automation
--ask-pass
--ask-become-pass
-u <username>
--private-key=<key>
(use /dev/null
to explicitly avoid SSH keys).bashrc
or something): export ANSIBLE_DISPLAY_SKIPPED_HOSTS=false; export ANSIBLE_DISPLAY_OK_HOSTS=false
ansible {all|<target>} -i <inventory> [-m <module>] [-a <module-arg>]
all -i <host>,
(with the comma).all -i localhost, --connection=local
.... -m ping
... -a <cmd>
... -a 'bash -c "nvidia-smi > /dev/null"'
ansible <...> -m setup -a 'filter=ansible_os_*'
(example fact filter)ansible-playbook <playbook>
ansible-playbook -i <hosts> <playbook>
ansible-playbook -l <group|host> <playbook>
ansible-playbook -t <tag> <playbook>
!vault ...
output directly into the configs to use the encrypted value in.~/.ansible_vault/<name>
(with appropriate parent dir perms). A generated [a-zA-Z0-9]{32}
string is more than strong enough.ansible-vault encrypt_string --vault-password-file=~/.ansible_vault/stuff
ansible-playbook --vault-password-file=<file> <...>
no_log
in tasks handling secrets.Config locations:
/etc/ansible/ansible.cfg
~/.ansible.cfg
ansible.cfg
ANSIBLE_CONFIG=ansible.cfg
Example config:
[defaults]
host_key_checking = false
executable = /bin/bash
#interpreter_python = auto
interpreter_python = /usr/bin/python3
#inventory = hosts.ini
#roles_path = ansible-roles:~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
#jinja2: trim_blocks:False
at the top of the file to avoid removing the newline after a block.ipaddr
(deprecated), ansible.netcommon.ipaddr
(deprecated) and ansible.utils.ipaddr
.{{ some_address | ansible.utils.ipaddr('address') }}
ansible.utils.ipv4
and ansible.utils.ipv6
ansible.utils.ipaddr('address')
ansible.utils.ipaddr('host')
ansible.utils.ipaddr('address/prefix')
ansible.utils.ipaddr('network')
ansible.utils.ipaddr('subnet')
ansible.utils.ipaddr('prefix')
ansible.utils.ipaddr('netmask')
ansible.utils.ipv4 | ansible.utils.ipaddr('broadcast')
ansible.utils.ipaddr('size')
ansible.utils.ipaddr('net') | ansible.utils.ipaddr(1)
(-1
for last address)ansible.utils.ipaddr('peer')
ansible.utils.ipv4('ipv6')
ansible.utils.hwaddr
Combine key-value pairs to string:
vars:
qm_params:
name: "{{ vm.name }}"
description: "{{ vm.description | default('') }}"
qm_params_string: "{{ vm_config.items() | map('join', '=') | map('regex_replace', '^([^=]*)=(.*)$', '--\\1=\"\\2\"') | join(' ') }}"
Probably caused by a password-protected SSH key. Add --private-key=<keyfile>
to specify which SSH key to use or --private-key=/dev/null
to avoid using any SSH key.