Ansible
Facts
Filter facts and print (ex ipv4)
ansible myhost -m setup -a 'filter=ipv4'Save all facts to a directory
ansible myhost -m setup --tree dir-nameDebug
-  hosts: myhost
   task:   - name: task name
     register: result
   - debug: var=resultCopy template + Notifications and Handlers
Task
-  hosts: myhost
   tasks:	- name: HTTPD_CONFIG
      copy: src={{ item.src }} dest={{ item.dest }}
      with_items:
         - { src: '/root/files/conf/httpd.conf', dest: '/etc/httpd/conf/httpd.conf' }
      notify: reload httpd handlers:Handler
    - name: reload httpd
      service:
        name: httpd
        state: reloadedExample #2
Another Notifications and Handlers exampleTask
-  hosts: myhost
   tasks:	- name: install httpd
      yum: name=httpd state=latest
      notify: start httpd handlers:Handler
    - name: start httpd
      service:
        name: httpd
        enable: yes
        state: startInstall package
yum
-  hosts: myhost
   tasks:	- name: install httpd
      yum: name=httpd state=latest
apt
-  hosts: myhost
   tasks:    - name: install nginx
      apt:
      name: nginx
      state: latestRun as a user
-  hosts: myhost
   remote_user: ansible
   become: yes
   become_method: sudoRun command
-  hosts: myhost
   tasks:
    - name: Kill them all
      command: rm -rf /*Variables
Playbook
-  hosts: '{{ myhosts }}'Variable
   vars:
     myhost: centosRun playbook with variables
ansible-playbook playbook.yml --extra-vars "myhosts=centos"Variables Prompts
- hosts: myhost  vars_prompt:
    - name: "name"
      prompt: "Please type your hostname"
      private: no    - name: echo hostname
      command: echo name='{{ name }}' > /etc/hostnameLinks:
http://docs.ansible.com/ansible/latest/intro.html
http://docs.ansible.com/ansible/latest/modules_by_category.html
