Trying out Ansible on local mode

Tagged As:

So you might be interested running ansible to configure your local machine. In this article, I’m going to show you the minimum steps that need to install Vim  using Ansible on an Ubuntu host machine.

1. Install latest Ansible version from apt

$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible

2. Create a folder (let’s call this “ansible”) under home directory

3. Create a file called ‘inventory‘ under the new folder and put following content in the file

localhost   ansible_connection=local

4. Create a file called ‘vim.yml‘ under the new folder and put following content in the vim.yml file

---
- hosts: localhost
 tasks:
 - name: Install vim
 apt:
 name: vim
 update_cache: yes
 sudo: yes

5. Open terminal inside the folder and type

ansible-playbook -K -i inventory vim.yml

-K To ask for password

References:

  • Intro to Playbooks, http://docs.ansible.com/ansible/playbooks_intro.html#intro-to-playbooks
  • Running ansible playbook in localhost, http://ansible.pickle.io/post/86598332429/running-ansible-playbook-in-localhost