changeset 0:10185cc821e4

add
author k178572
date Wed, 20 Sep 2017 18:12:15 +0900
parents
children fa8aa41596b7
files hosts main.yml tasks/install-firewalld.yml tasks/install-httpd.yml tasks/install-mariadb.yml tasks/install-php-mbstring.yml tasks/install-php.yml tasks/setting-firewalld.yml tasks/setting-mariadb.yml tasks/setting-wordpress.yml
diffstat 10 files changed, 120 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hosts	Wed Sep 20 18:12:15 2017 +0900
@@ -0,0 +1,1 @@
+test-fedora
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.yml	Wed Sep 20 18:12:15 2017 +0900
@@ -0,0 +1,11 @@
+- hosts: all
+  user: mitsuki
+  tasks:
+    - include: tasks/install-firewalld.yml
+    - include: tasks/setting-firewalld.yml
+    - include: tasks/install-httpd.yml
+    - include: tasks/install-php.yml
+    - include: tasks/install-mariadb.yml
+    - include: tasks/install-php-mbstring.yml
+    - include: tasks/setting-mariadb.yml
+    - include: tasks/setting-wordpress.yml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tasks/install-firewalld.yml	Wed Sep 20 18:12:15 2017 +0900
@@ -0,0 +1,5 @@
+    - name: install dnf python-firewall
+      become: yes
+      dnf: name={{ item }} state=latest
+      with_items:
+        - python-firewall
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tasks/install-httpd.yml	Wed Sep 20 18:12:15 2017 +0900
@@ -0,0 +1,13 @@
+    - name: install dnf packages
+      become: yes
+      dnf: name={{ item }} state=latest
+      with_items:
+      - httpd
+
+    # start httpd
+    - service: name=httpd state=restarted
+      become: yes  
+
+    # chkconfig enabled httpd 
+    - service: name=httpd enabled=yes
+      become: yes
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tasks/install-mariadb.yml	Wed Sep 20 18:12:15 2017 +0900
@@ -0,0 +1,16 @@
+    - name: install dnf packages
+      dnf: name={{ item }} state=latest
+      become: yes
+      with_items:
+      - mariadb
+      - mariadb-server
+      - MySQL-python
+
+# start mariadb
+    - service: name=mariadb state=restarted
+      become: yes  
+
+# chkconfig enabled mariadb 
+    - service: name=mariadb enabled=yes
+      become: yes
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tasks/install-php-mbstring.yml	Wed Sep 20 18:12:15 2017 +0900
@@ -0,0 +1,5 @@
+    - name: install dnf packages
+      become: yes
+      dnf: name={{ item }} state=latest
+      with_items:
+      - php-mbstring
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tasks/install-php.yml	Wed Sep 20 18:12:15 2017 +0900
@@ -0,0 +1,6 @@
+    - name: install dnf packages
+      become: yes
+      dnf: name={{ item }} state=latest
+      with_items:
+      - php
+      - php-mysqlnd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tasks/setting-firewalld.yml	Wed Sep 20 18:12:15 2017 +0900
@@ -0,0 +1,10 @@
+- name: Setting Firewalld
+  firewalld: permanent=true service={{ item.service }} state={{ item.state }}
+  with_items:
+    - { service: http, state: enabled }
+    - { service: https, state: enabled }
+  become: yes
+
+- name: Restart service
+  service: name=firewalld state=restarted enabled=yes
+  become: yes
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tasks/setting-mariadb.yml	Wed Sep 20 18:12:15 2017 +0900
@@ -0,0 +1,15 @@
+- name: データベース wordpress を作成
+  become: yes
+  mysql_db:
+    name: wordpress
+    state: present
+    encoding: utf8
+
+- name: MySQLユーザー wordpress を作成し,wordpress.* にすべての権限を与える
+  become: yes
+  mysql_user:
+    name: wordpress
+    password: "hZzTwWuTeN"
+    priv: "wordpress.*:ALL"
+    host: localhost
+    state: present
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tasks/setting-wordpress.yml	Wed Sep 20 18:12:15 2017 +0900
@@ -0,0 +1,38 @@
+    - name: WordPress Download
+      get_url: url="https://ja.wordpress.org/wordpress-4.3.1-ja.tar.gz" dest=/tmp
+
+    - name: unarchive source
+      become: yes
+      command: tar zxvf /tmp/wordpress-4.3.1-ja.tar.gz chdir=/var/www/html
+
+    - name: change dir / files permission
+      become: yes
+      file: path=/var/www/html/wordpress owner=apache group=apache mode=0755 recurse=yes state=directory
+
+    - name: replace /etc/httpd/conf/httpd.conf
+      become: yes
+      replace: dest=/etc/httpd/conf/httpd.conf regexp='^DocumentRoot "/var/www/html"$' replace='DocumentRoot "/var/www/html/wordpress"' backup=yes
+
+    - name: replace /etc/httpd/conf/httpd.conf
+      become: yes
+      replace: dest=/etc/httpd/conf/httpd.conf regexp='^<Directory "/var/www">$' replace='<Directory "/var/www/wordpress">' backup=yes
+
+    - name: replace /etc/httpd/conf/httpd.conf
+      become: yes
+      replace: dest=/etc/httpd/conf/httpd.conf regexp='^AllowOverride None$' replace='AllowOverride All' backup=yes
+
+    - name: cp wp-config.php
+      become: yes
+      command: cp '/var/www/html/wordpress/wp-config-sample.php' '/var/www/html/wordpress/wp-config.php' creates=/var/www/html/wordpress/wp-config.php
+
+    - name: replace /var/www/html/wordpress/wp-config.php
+      become: yes
+      replace: dest=/var/www/html/wordpress/wp-config.php regexp='database_name_here' replace='wordpress'
+
+    - name: replace /var/www/html/wordpress/wp-config.php
+      become: yes
+      replace: dest=/var/www/html/wordpress/wp-config.php regexp='username_here' replace='wordpress'
+
+    - name: replace /var/www/html/wordpress/wp-config.php
+      become: yes
+      replace: dest=/var/www/html/wordpress/wp-config.php regexp='password_here' replace='hZzTwWuTeN'