HON’s Wiki # Ansible

Home / Automation

Contents

Usage

Ad Hoc

Playbooks

Vault

Configuration

Config locations:

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

Templating

YAML Files

ipaddr Filter

Examples

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(' ') }}"

Troubleshooting

Ansible Freezes when Connecting

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.


hon.one | HON95/wiki | Edit page