Skip to content

Instantly share code, notes, and snippets.

Created December 27, 2014 04:10
Show Gist options
  • Save anonymous/77fe95d3e3b560ca9d29 to your computer and use it in GitHub Desktop.
Save anonymous/77fe95d3e3b560ca9d29 to your computer and use it in GitHub Desktop.
dotinstall ansible tutorial
[defaults]
hostfile = ./hosts
[web]
192.168.43.52
[db]
192.168.43.53
---
- hosts: all
sudo: yes
vars:
username: akiyama
tasks:
- name: add a new user
user: name={{username}} state=present
- name: install libselinux-python
yum: name=libselinux-python state=latest
- hosts: web
sudo: yes
tasks:
- name: install apache
yum: name=httpd state=latest
- name: start apache and enabled
service: name=httpd state=started enabled=yes
- name: change owner
file: dest=/var/www/html owner=vagrant recurse=yes
- name: copy index.html
copy: src=index.html dest=/var/www/html/index.html owner=vagrant
- name: install php packages
yum: name={{item}} state=latest
with_items:
- php
- php-devel
- php-mbstring
- php-mysql
notify:
- restart apache
- name: copy hello.php
copy: src=./hello.php dest=/var/www/html/hello.php owner=vagrant
handlers:
- name: restart apache
service: name=httpd state=restarted
- hosts: db
sudo: yes
tasks:
- name: install mysql
yum: name={{item}} state=latest
with_items:
- mysql-server
- MySQL-python
- name: start mysql and enabled
service: name=mysqld state=started enabled=yes
- name: create database
mysql_db: name=mydb state=present
- name: create mysql user
mysql_user: name=dbuser password=dbpassword priv=mydb.*:ALL state=present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment