ansible production -m command -a uptime
ansible testserver -m fetch -a 'src=filepath dest=filename flat=yes'
ansible bruce.home -m debug -a "msg=test"
- name: Play to get the gathre facts content
hosts: DEV1
tasks:
- name: print ansible_facts
debug:
var: ansible_facts["kernal"]
ansible-playbook -l hosts playbook.yml
ansible-playbook --limit hosts playbook.yml
ansible-playbook --syntax-check playbook.yml
become: yes
become_user: username
#su: yes
#su_user: username
ansible-vault encrypt secrets.yaml
ansible-vault decrypt secrets.yaml
EDITOR=vim ansible-vault edit secrets.yml
ansible-playbook playbook.yaml --ask-vault-password
ansible-playbook playbook.yaml --ask-password-file FILES
ansible-playbook --vault-password-file /path/to/my/vault-password-file site.yml
ansible-playbook --vault-password-file my-vault-password-client.py
- name: Load Secrets
include_vars:
file: secrets.yaml
name: secrets
ansible-playbook -i "localhost," -c local workstation.yml
ansible-playbook site.yml --ask-sudo-pass
- debug:
args:
msg: 'System {{ ansible_distribution_release }}'
ansible host -m setup
name: Ansible check directory exists
stat:
path: /etc/pihole
register: folderstat
debug:
msg: "{{ folderstat }}"
set_fact: test=false
when: folderstat.stat.exists == false
ansible group -m ping
ansible group -m command -a "sudo touch /tmp/ansible.txt" --ask-sudo-pass
- name: Include vm variables
include_vars:
file: vars/vms.yml
name: vms
set_fact:
vm: "{{ vms.all.hosts[fqdn] }}"
- name: Create a data container
community.docker.docker_container:
name: mydata
image: busybox
volumes:
- /data