~/snippets/ansible
Published on

Ansible

129 words1 min read

Get a list of facts

ansible -m setup localhost | sed '1c {' | jq '.ansible_facts | keys'

Run playbook without inventory file

ansible-playbook --connection=local --inventory xxx.xxx.xxx.xxx, playbook.yml # be aware of the comma
ansible all -i localhost, -m setup -c local

Output shell command

- name: debug
  shell: ls -al /var/www/
  register: out

- name: out
  debug:
    var: out.stdout_lines