Johannes Rothe 649e48930e
Add ansible roles and playbook to setup LEMP stack
Ansible roles added:
 * nginx
 * php
 * mysql
 * wordpress

Additionally adds a Vagrantfile to setup two machines using the new
playbook for testing.
2023-08-17 20:54:40 +02:00

47 lines
1.2 KiB
YAML

---
- name: Install relevant packages
ansible.builtin.apt:
update_cache: true
cache_valid_time: 3600
name:
- mariadb-client
- mariadb-server
- python3-pymysql
state: present
become: true
- name: Set new root user password
community.mysql.mysql_user:
name: root
password: "{{ mysql_root_password }}"
check_implicit_admin: true
login_unix_socket: /var/run/mysqld/mysqld.sock
become: true
- name: Create wordpress user with password, grant wordpress permissions
community.mysql.mysql_user:
state: present
name: "{{ wordpress.db_user }}"
login_user: root
login_password: "{{ mysql_root_password }}"
password: "{{ wordpress.db_pass }}"
priv:
"wordpress.*": "ALL,GRANT"
login_unix_socket: /var/run/mysqld/mysqld.sock
become: true
- name: Store the config for task indempotency as written in the mysql collection docs
ansible.builtin.template:
src: "my.cnf.j2"
dest: "/root/.my.cnf"
mode: "0400"
become: true
notify: restart mysql
- name: Setup database for wordpress
community.mysql.mysql_db:
name: "{{ wordpress.db_name }}"
state: present
login_unix_socket: /var/run/mysqld/mysqld.sock
become: true