Skip to content

Instantly share code, notes, and snippets.

@rei999
Created July 17, 2013 23:10
Show Gist options
  • Save rei999/6025366 to your computer and use it in GitHub Desktop.
Save rei999/6025366 to your computer and use it in GitHub Desktop.
ansible - configure xfs file system, mount ebs, install MySql, php, nginx, create db user, create db, install git, pull from git
- name: configure instances
hosts: ec2-servers
vars:
work_dir: /vol/src/application
user: ec2-user
sudo: yes
tasks:
- name: update machine with latest packages
action: command yum -y update
- name: install xfsprogs
action: yum pkg=xfsprogs state=latest
- name: format new volume
filesystem: fstype=xfs dev=/dev/xvdf
- name: edit fstab and mount the vol
action: mount name={{mount_dir}} src=/dev/xvdf opts=noatime fstype=xfs state=mounted
- name: install php
action: yum pkg=php state=latest
- name: install php-mysql
action: yum pkg=php-mysql state=latest
- name: install nginx
action: yum pkg=nginx state=latest
- name: ensure nginx is running
action: service name=nginx state=started
- name: install mysql server
action: yum pkg=mysql-server state=latest
- name: make sure mysql is running
action: service name=mysqld state=started
- name: install python mysql
action: yum pkg=MySQL-python state=latest
- name: create database user
action: mysql_user user=admin password=1234qwer priv=*.*:ALL state=present
- name: create db
action: mysql_db db=ansible state=present
- name: create src directory
action: file path={{work_dir}} state=directory owner=root group=root mode=0751
- name: install git
action: yum pkg=git state=latest
- name: copy private key
action: template src=~/.ssh/id_rsa.pub dest=~/.ssh/id_rsa.pub
- name: copy public key
action: template src=~/.ssh/id_rsa dest=~/.ssh/id_rsa
- name: git checkout source
action: git repo=ssh://[email protected]:{your_git_repo}.git dest={{work_dir}} version=unstable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment