Skip to content

Instantly share code, notes, and snippets.

@joseche
Last active October 5, 2015 17:29
Show Gist options
  • Select an option

  • Save joseche/ccdb1bc01e169e11e435 to your computer and use it in GitHub Desktop.

Select an option

Save joseche/ccdb1bc01e169e11e435 to your computer and use it in GitHub Desktop.
Ansible examples
---
- name: Ansible examples to copy & paste
hosts: all
vars:
firstvar: firstvalue
secondvar: secondvalue
roles:
- common
- webservers
tasks:
- name: Install epel-release
yum: name=epel-release state=installed
- name: Upgrade all packages
yum: name=* state=latest update_cache=yes
- name: Install base packages
yum: name={{ item }} state=present
with_items:
- vim
- yum-utils
- net-snmp
- net-snmp-utils
- name: Restart a service
service: name=nginx state=restarted
- name: Linking files
file: >
dest=/etc/nginx/sites-enabled/default
src=/etc/nginx/sites-available/default
state=link
- name: Creates directory
file: path=/src/www state=directory owner=www-data group=www-data mode=0775
- name: Templating configurations
template:
src=nginx.conf.j2
dest=/etc/nginx/nginx.conf
mode=0644
owner=root
group=root
- user: name=jose shell=/bin/bash groups=admins,developers append=yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment