Skip to content

Instantly share code, notes, and snippets.

@waday
Last active October 23, 2016 06:34
Show Gist options
  • Save waday/cdd844cfe95e2fd96f12c66fc8a7f363 to your computer and use it in GitHub Desktop.
Save waday/cdd844cfe95e2fd96f12c66fc8a7f363 to your computer and use it in GitHub Desktop.
Ansible Playbook: Ethna + Apache + PHP + MySQL on CentOS 6
---
- name: setup-ethna
hosts: all
become: yes
become_user: root
gather_facts: False
vars:
project_owner: vagrant
project_owner_home: /home/{{ project_owner }}
project_name: sample
project_home: "{{ project_owner_home }}/{{ project_name }}"
tasks:
- name: install epel-release
yum: name=epel-release state=present
- name: install libselinux-python
yum: name=libselinux-python state=present
- name: disable selinux
selinux: state=disabled
- name: install rpm packages for ethna
yum: name={{ item }} state=present
with_items:
- httpd
- mysql
- mysql-server
- php
- php-mysql
- php-pear
- php-Smarty
- name: pear upgrade
shell: pear upgrade pear
ignore_errors: True
- name: pear channel-discover pear.ethna.jp
shell: pear channel-discover pear.ethna.jp
ignore_errors: True
- name: pear update-channels
shell: pear update-channels
- name: pear install ethna
pear: name={{ item }} state=present
with_items:
- ethna/ethna
- DB-1.8.2
- name: create project home directory
file: path={{project_home}} state=directory owner={{ project_owner }} group={{ project_owner }} mode=0755
- name: not create project if exist project files
stat: path={{ project_home }}/www
register: is_created_project
- name: create project
shell: ethna add-project -b {{ project_home }} {{ project_name }}
when: is_created_project.stat.exists == False
become_user: "{{ project_owner }}"
- name: create symlink index.php
file: src={{ project_home }}/www/index.php dest=/var/www/html/index.php owner={{ project_owner }} group={{ project_owner }} state=link
- name: create symlink css directory
file: src={{ project_home }}/www/css dest=/var/www/html/css owner={{ project_owner }} group={{ project_owner }} state=link
- name: chmod {{ project_owner_home }} home
shell: chmod 755 {{ project_owner_home }}
- name: configure httpd.conf
replace: >-
dest='/etc/httpd/conf/httpd.conf'
regexp='^DirectoryIndex index.html index.html.var'
replace='DirectoryIndex index.php index.html index.html.var'
- name: enable and start httpd service
service: name=httpd enabled=yes state=started
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment