Differences between revisions 1 and 2
Revision 1 as of 2018-02-22 01:01:35
Size: 552
Editor: SamatJain
Comment:
Revision 2 as of 2018-07-02 19:38:08
Size: 928
Editor: SamatJain
Comment:
Deletions are marked like this. Additions are marked like this.
Line 12: Line 12:
{{{ {{{#!highlight yaml
Line 25: Line 25:
or specify hosts: all:

{{{#!highlight yaml
- hosts: all
  become: yes
  become_user: root
  tasks:
   - name: Install Nginx
     apt:
       name: nginx
       state: installed
       update_cache: true
}}}

and then invoke ansible with:

{{{#!highlight sh numbers=off
ansible-playbook -i 'localhost,' -c local Playbook.ansible.yml
}}}

Installing ansible

# Official PPA for Ubuntu
sudo apt-add-repository -y ppa:ansible/ansible
sudo apt-get update
sudo apt-get install -y ansible

Playbooks meant to only be run locally

   1 - hosts: local
   2   connection: local
   3   become: yes
   4   become_user: root
   5   tasks:
   6    - name: Install Nginx
   7      apt:
   8        name: nginx
   9        state: installed
  10        update_cache: true

or specify hosts: all:

   1 - hosts: all
   2   become: yes
   3   become_user: root
   4   tasks:
   5    - name: Install Nginx
   6      apt:
   7        name: nginx
   8        state: installed
   9        update_cache: true

and then invoke ansible with:

ansible-playbook -i 'localhost,' -c local Playbook.ansible.yml

Good articles

SamatsWiki: Ansible (last edited 2021-06-24 18:44:34 by SamatJain)