You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.0 KiB
YAML
94 lines
2.0 KiB
YAML
- name: Provisioning database server (maria Db)
|
|
hosts: back
|
|
handlers:
|
|
- name: restart mysql
|
|
service:
|
|
name: mysql
|
|
state: restarted
|
|
vars:
|
|
mysql_listen_address: "{{ ansible_default_ipv4.address }}"
|
|
mysql_user: wordpress
|
|
mysql_password: password
|
|
tasks:
|
|
# - name: set hostname
|
|
# hostname:
|
|
# name: "{{ inventory_hostname }}"
|
|
|
|
- name: install packages
|
|
apt:
|
|
name:
|
|
- mariadb-server
|
|
- python-mysqldb
|
|
update_cache: yes
|
|
|
|
- name: ensure service
|
|
service:
|
|
name: mysql
|
|
state: started
|
|
enabled: yes
|
|
|
|
- name: "set maria db options"
|
|
notify:
|
|
- "restart mysql"
|
|
lineinfile:
|
|
path: /etc/mysql/mariadb.conf.d/50-server.cnf
|
|
regexp: "{{ item.regexp }}"
|
|
line: "{{ item.line }}"
|
|
with_items:
|
|
- regexp: "^bind-address"
|
|
line: "bind-address = {{ mysql_listen_address }}"
|
|
|
|
- name: create user
|
|
mysql_user:
|
|
state: present
|
|
name: '{{ mysql_user }}'
|
|
password: '{{ mysql_password }}'
|
|
priv: '*.*:ALL'
|
|
host: '%'
|
|
|
|
|
|
- name: create database
|
|
mysql_db:
|
|
name: wordpress
|
|
|
|
|
|
|
|
|
|
- name: Provisioning webserver server (apache + WP)
|
|
hosts: front
|
|
vars:
|
|
front_packages:
|
|
- apache2
|
|
- libapache2-mod-php
|
|
- php-mysql
|
|
- unzip
|
|
- tar
|
|
tasks:
|
|
# - name: set hostname
|
|
# hostname:
|
|
# name: "{{ inventory_hostname }}"
|
|
|
|
- name: install webserver
|
|
apt:
|
|
name: "{{ front_packages }}"
|
|
state: latest
|
|
update_cache: yes
|
|
|
|
- name: set document root
|
|
lineinfile:
|
|
path: /etc/apache2/sites-enabled/000-default.conf
|
|
regexp: 'DocumentRoot (.*)$'
|
|
line: "DocumentRoot /var/www/html/wordpress"
|
|
|
|
- name: restart apache
|
|
service:
|
|
name: apache2
|
|
state: restarted
|
|
|
|
- name: download wordpress
|
|
unarchive:
|
|
src: https://wordpress.org/latest.zip
|
|
dest: /var/www/html
|
|
remote_src: yes
|
|
owner: www-data
|