Skip to content

Instantly share code, notes, and snippets.

@afgane
Created June 23, 2016 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save afgane/fecd4a0c611e7a63ec11e8632f283adf to your computer and use it in GitHub Desktop.
Save afgane/fecd4a0c611e7a63ec11e8632f283adf to your computer and use it in GitHub Desktop.
An Ansible playbook for setting up a host to run Ansible itself.

Create an inventory file such called hosts with the following content (adjusting the IP address)

[ansible-hosts]
129.114.18.39 ansible_ssh_private_key_file=key_pair.pem ansible_ssh_user=ubuntu  # Ubuntu target

From an Ansible-enabled machine, download playbook.yml and run it with

ansible-playbook -i hosts playbook.yml
---
- hosts: ansible-hosts
become: yes
become_user: root
vars:
- venv_dir: /tmp/ansible_venv
tasks:
- name: Add Ansible PPA
apt_repository: repo="ppa:ansible/ansible" update_cache=no
- name: Update APT cache
apt: update_cache=yes
- name: Install system packages
apt: pkg={{ item }} state=latest install_recommends=no
with_items:
- ansible
- gcc
- git-core
- python-pip
- python-virtualenv
- software-properties-common
- wget
- vim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment