You are on page 1of 1

SHEET

$ansible inventory
call a shell command: general inventory:
-a "$command" /etc/ansible/hosts
call with sudo rights: shell variable:
--sudo $ANSIBLE_HOSTS

C H E AT
test if machine responses: normale entry:
-m ping www.example.com
call an arbitrary module: multi-definition:
-m $module -a "$argument" db[0-9].example.com
gather specific facts: custom ip:
-m setup -a "filter=*distri*" ansible_ssh_host
grouping:

ANSIBLE
$ansible-playbook [group]
specific user:
call a book: ansible_ssh_user
$host some/playbook.yaml specific port:
run in parallel: ansible_ssh_port
-f 10
list affected hosts: complex playbook.yaml
--list-hosts"
loop over items:
basic playbook.yaml - name: copy file
copy: src={{item.src}} \
YAML format: dest={{item.dst}}
--- with_items:
- hosts:all - {src: a, dst: b}
launch task: - {src: k, dst: l}
- name: check avail conditionals:
ping: - name: reboot Debian
variables: command: shutdown -h now
vars: when: ansible_os_family == "Debian"
rack: green Roles:
include tasks: - hosts: webserver
tasks: roles:
- { include: tasks/my.yml, user=alice } - common
include handlers: - dbservers
handlers: roles/
- { include: handlers/my.yml } common/
call depedency: files/
tasks: templates/
- name: copy file tasks/main.yml
copy: src=a dest=b handlers/main.yml
notify: vars/main.yml
- restart sshd meta/main.yml
handlers: webservers/
- name: restart sshd ...

Content by Roland Wolters - liquidat.wordpress.com


Designed by Wall-Skills.com - Knowledgable 1-Pagers

You might also like