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.

97 lines
2.2 KiB
YAML

2 weeks ago
- name: Provisioning database server (maria Db)
hosts: back
handlers:
- name: "restart mysql"
service:
name: "{{ mysql_service_name }}"
state: restarted
tasks:
# - name: set hostname
# hostname:
# name: "{{ inventory_hostname }}"
- name: import os variables
include_vars: "{{ playbook_dir }}/vars/{{ ansible_os_family }}.yml"
- name: install packages in debian
apt:
name:
- mariadb-server
- python-mysqldb
update_cache: yes
when: ansible_os_family == "Debian"
- name: install packages in redhat
when: ansible_os_family == "RedHat"
yum:
name:
- mariadb-server
- MySQL-python
update_cache: yes
- name: ensure service
service:
name: "{{ mysql_service_name }}"
state: started
enabled: yes
- name: "set maria db options"
ignore_errors: yes
notify:
- "restart mysql"
lineinfile:
path: "{{ mysql_config_path }}"
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
with_items:
- "{{mysql_lines}}"
- 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