as your current user ? --user use different username for SSH --ask-pass ask for SSH password --sudo run commands through sudo --ask-sudo-pass ask for sudo password --sudo-user sudo to different non-root user ansible -u bwayne --sudo --sudo-user batman ...
• Can be written in any language, just needs to – accept File IO – output to Stdout • Help is out there for Rubyists: https://github.com/ansible/ansible-for-rubyists
design plans • Written in YAML • Intended to be configuration, not a progamming script • Consists of one or more 'plays' $ ansible-playbook playbook.yml
module tasks: - name: ensure apache is at the latest version apt: pkg=apache2 state=latest Description Module $ ansible -m apt -a 'pkg=apache2 state=latest' Arguments
service to happen at some point, not neccasarily immediatley. To do this they notify a handler, which acts after the play --- - hosts: webservers tasks: - name: write the apache config file template: src=/srv/httpd.j2 dest=/etc/httpd.conf notify: - restart apache # … other things that modify apache setup … handlers: - name: restart apache service: name=httpd state=restarted
source apt: pkg=build-essential state=present - name: oh we also need git-core as well apt: pkg=git-core state=present - name: must not forget curl too apt: pkg=curl state=present - name: How many more things are there ?!? ... Sometimes, loops can really help - name: required for compiling Ruby from source apt: pkg={{ item }} state=present with_items: - build-essential - git-core - curl - ...
executed against the server based on current variables vars: awesome: true tasks: - shell: echo “This machine is awesome !” when: awesome tasks: - name: "shutdown Debian flavored systems" command: /sbin/shutdown -t now when: ansible_os_family == "Debian"
"6.00", "ansible_os_family": "Debian", "ansible_pkg_mgr": "apt", "ansible_processor": [ "Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz" ], "ansible_processor_cores": 1, "ansible_swapfree_mb": 665, "ansible_swaptotal_mb": 1021, ... Ansible provides a ginormous amount of machine facts as variables during the play
host_vars/ host1 host2 roles/ ... Site.yml - referencing all other playbooks Seperate production inventory file Group and host specific variables in files named by group / host Split everything else into roles