Created
December 27, 2014 04:10
-
-
Save anonymous/77fe95d3e3b560ca9d29 to your computer and use it in GitHub Desktop.
dotinstall ansible tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[defaults] | |
hostfile = ./hosts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[web] | |
192.168.43.52 | |
[db] | |
192.168.43.53 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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