Merge "Allow usage of Fedora24"

This commit is contained in:
Jenkins 2016-10-30 03:35:23 +00:00 committed by Gerrit Code Review
commit dc46a8c64d
7 changed files with 204 additions and 8 deletions

View File

@ -1,11 +1,20 @@
---
- name: Haproxy install
apt:
package:
name="{{ item }}"
state=latest
update_cache=yes
with_items:
- haproxy
when: ansible_distribution == 'Ubuntu'
- name: Haproxy install
package:
name="{{ item }}"
state=latest
with_items:
- haproxy
when: ansible_distribution == 'Fedora'
- name: Enable haproxy service
replace:
@ -13,6 +22,7 @@
regexp: "ENABLED=0"
replace: "ENABLED=1"
backup: no
when: ansible_distribution == 'Ubuntu'
- name: Place the haproxy configuration file
copy:
@ -20,6 +30,15 @@
dest: /etc/haproxy/haproxy.cfg
owner: root
group: root
when: ansible_distribution == 'Ubuntu'
- name: Place the haproxy configuration file
copy:
src: templates/haproxy_fedora.cfg.j2
dest: /etc/haproxy/haproxy.cfg
owner: root
group: root
when: ansible_distribution == 'Fedora'
- name: Add web servers to the haproxy
lineinfile:
@ -32,4 +51,3 @@
no_log: True
- service: name=haproxy state=restarted enabled=yes

View File

@ -0,0 +1,34 @@
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
option dontlognull
option redispatch
retries 3
contimeout 5000
clitimeout 50000
srvtimeout 50000
errorfile 400 /usr/share/haproxy/400.http
errorfile 403 /usr/share/haproxy/403.http
errorfile 408 /usr/share/haproxy/408.http
errorfile 500 /usr/share/haproxy/500.http
errorfile 502 /usr/share/haproxy/502.http
errorfile 503 /usr/share/haproxy/503.http
errorfile 504 /usr/share/haproxy/504.http
listen webfarm
bind 0.0.0.0:80
mode http
stats enable
stats uri /haproxy?stats
balance roundrobin
option httpclose
option forwardfor

View File

@ -0,0 +1,19 @@
---
- name: Wait until server is up and runnning
local_action: wait_for port=22 host="{{ ansible_ssh_host | default(inventory_hostname) }}" search_regex=OpenSSH delay=10
become: no
- name: Check if running on Fedora
raw: "[ -f /etc/fedora-release ]"
register: fedora_release
ignore_errors: yes
- name: Install python2 for Ansible
raw: dnf install -y python2 python2-dnf libselinux-python
register: result
until: result|success
when: fedora_release.rc == 0
- name: Set SELinux to permisive
selinux: policy=targeted state=permissive
when: fedora_release.rc == 0

View File

@ -8,9 +8,17 @@
- name: install scsitools
package: name=scsitools state=latest
when: ansible_distribution == 'Ubuntu'
- name: install sg3_utils
package: name=sg3_utils state=latest
when: ansible_distribution == 'Fedora'
- shell: /sbin/rescan-scsi-bus
when: diskflag.stat.exists == false
when: diskflag.stat.exists == false and ansible_distribution == 'Ubuntu'
- shell: /bin/rescan-scsi-bus.sh
when: diskflag.stat.exists == false and ansible_distribution == 'Fedora'
- shell: parted -s "{{ app_env.block_device_name }}" mklabel msdos
when: diskflag.stat.exists == false
@ -36,7 +44,15 @@
file: path=/var/lib/mysql state=directory
- name: Install NFS server
package: name=nfs-kernel-server state=latest
package:
name=nfs-kernel-server
state=latest
update_cache=yes
when: ansible_distribution == 'Ubuntu'
- name: Install NFS server
package: name=nfs-utils state=latest
when: ansible_distribution == 'Fedora'
- name: Setup NFS database access
lineinfile:
@ -57,6 +73,10 @@
shell: exportfs -a
- service: name=nfs-kernel-server state=restarted enabled=yes
when: ansible_distribution == 'Ubuntu'
- service: name=nfs-server state=restarted enabled=yes
when: ansible_distribution == 'Fedora'
- name: Mount the database data directory
mount:
@ -66,12 +86,29 @@
fstype: nfs
- name: Install mysql and libraries
package: name={{ item }} state=latest
package:
name="{{ item }}"
state=latest
update_cache=yes
with_items:
- mysql-server
- python-mysqldb
when: ansible_distribution == 'Ubuntu'
- name: Install mysql and libraries
package:
name="{{ item }}"
state=latest
with_items:
- mariadb-server
- python2-mysql
when: ansible_distribution == 'Fedora'
- service: name=mysql state=stopped enabled=yes
when: ansible_distribution == 'Ubuntu'
- service: name=mariadb state=stopped enabled=yes
when: ansible_distribution == 'Fedora'
- stat: path=/etc/mysql/my.cnf
register: mysqlflag
@ -90,12 +127,26 @@
- name: Configure mysql 5.6+
replace:
dest: "/etc/mysql/mysql.conf.d/mysqld.cnf"
regexp: '^bind-address[ \t]*=[ ]*127\.0\.0\.1'
replace: "bind-address = {{ local_ip.stdout }}"
backup: no
when: mysqlflag.stat.exists == true
- stat: path=/etc/my.cnf
register: mariadbflag
- name: Configure MariaDB 10.1
ini_file:
dest=/etc/my.cnf
section=mysqld
option=bind-address
value={{ local_ip.stdout }}
when: mariadbflag.stat.exists == true
- service: name=mysql state=started enabled=yes
when: ansible_distribution == 'Ubuntu'
- service: name=mariadb state=started enabled=yes
when: ansible_distribution == 'Fedora'
- name: create wordpress database
mysql_db:
@ -111,4 +162,3 @@
host: "%"
priv: 'decision2016.*:ALL'
state: present

View File

@ -1,6 +1,6 @@
---
- name: Apache and php 5
apt:
package:
name="{{ item }}"
state=latest
update_cache=yes
@ -11,6 +11,20 @@
- nfs-common
- unzip
- ssmtp
when: ansible_distribution == 'Ubuntu'
- name: Apache and php 5
package:
name="{{ item }}"
state=latest
with_items:
- httpd
- php
- php-mysqlnd
- nfs-utils
- unzip
- ssmtp
when: ansible_distribution == 'Fedora'
- shell: rm -rf /var/www/html/index.html
args:
@ -22,6 +36,15 @@
state: directory
owner: www-data
group: www-data
when: ansible_distribution == 'Ubuntu'
- name: Creates share directory for wpcontent
file:
path: /var/www/html/wp-content/uploads
state: directory
owner: apache
group: apache
when: ansible_distribution == 'Fedora'
- name: Mount the directory using private IP
mount:
@ -40,6 +63,10 @@
when: hostvars.cloud.database.openstack.private_v4 == ""
- lineinfile: dest=/etc/apache2/apache2.conf line="ServerName localhost"
when: ansible_distribution == 'Ubuntu'
- lineinfile: dest=/etc/httpd/conf/httpd.conf line="ServerName localhost"
when: ansible_distribution == 'Fedora'
- name: Download wordpress
get_url:
@ -87,8 +114,19 @@
shell: chown -R www-data:www-data /var/www/html
args:
warn: no
when: ansible_distribution == 'Ubuntu'
- name: Change ownership of wordpress
shell: chown -R apache:apache /var/www/html
args:
warn: no
when: ansible_distribution == 'Fedora'
- service: name=apache2 state=restarted enabled=yes
when: ansible_distribution == 'Ubuntu'
- service: name=httpd state=restarted enabled=yes
when: ansible_distribution == 'Fedora'
- name: Install wordpress command line tool
get_url:

View File

@ -36,6 +36,24 @@
plugin install /tmp/wordpress-importer.zip --activate
args:
warn: no
when: ansible_distribution == 'Ubuntu'
- name: Install wordpress importer plugin
shell: >
sudo -u apache /usr/local/bin/wp --path=/var/www/html
plugin install /tmp/wordpress-importer.zip
args:
warn: no
when: ansible_distribution == 'Fedora'
- name: Enable wordpress importer plugin
shell: >
sudo -u apache /usr/local/bin/wp --path=/var/www/html
plugin activate wordpress-importer
args:
warn: no
when: ansible_distribution == 'Fedora'
- name: Download wordpress sample posts
get_url:
@ -52,3 +70,10 @@
shell: >
sudo -u www-data wp --path=/var/www/html
import /tmp/posts/*.xml --authors=create --quiet
when: ansible_distribution == 'Ubuntu'
- name: Import wordpress posts
shell: >
sudo -u apache /usr/local/bin/wp --path=/var/www/html
import /tmp/posts/*.xml --authors=create --quiet
when: ansible_distribution == 'Fedora'

View File

@ -7,6 +7,18 @@
roles:
- "{{ action }}"
- name: Install python2 for ansible to work
hosts: dbservers, webservers, balancers, wps
gather_facts: false
user: "{{ app_env.ssh_user }}"
become: true
become_user: root
vars_files:
- "vars/{{ env }}.yml"
roles:
- common
environment: "{{ proxy_env }}"
- name: setup database
hosts: dbservers
user: "{{ app_env.ssh_user }}"