Skip to content

Instantly share code, notes, and snippets.

@Tronde
Created March 30, 2018 14:44
Show Gist options
  • Save Tronde/db576c10b6889470de80eaa659d7980a to your computer and use it in GitHub Desktop.
Save Tronde/db576c10b6889470de80eaa659d7980a to your computer and use it in GitHub Desktop.
Bei diesem Playbook handelt es sich um die tasks/main.yml-Datei, mit deren Hilfe ich meinen Wordpress-Blog auf einem neuen Ubuntu-Server wiederherstelle. Auch wenn der Blog damit erfolgreich ausgebracht werden konnte, kann es sicher noch etwas Feinschliff vertragen.
---
- name: Check for nginx, php-fpm and mysql-server
apt:
name: "{{ item }}"
state: present
with_items:
- nginx
- php-fpm
- mysql-server
- python-mysqldb
- php-mysql
- name: Unarchive DocumentRoot Tree
unarchive:
src: files/backup-documentroot.tar.bz2
dest: /
- name: Copy php-fpm-config to target node
copy:
src: files/php-fpm-pool.conf
dest: /etc/php/7.2/fpm/pool.d/mypool.conf
owner: root
group: root
mode: 0644
backup: yes
notify:
- reload php-fpm
- name: Create php-fpm log directory
file:
path: /var/www/tronde/sites/logs
state: directory
owner: tronde
group: www-data
mode: 0750
notify:
- reload php-fpm
- name: Touch php-fpm log file
file:
path: /var/www/tronde/sites/logs/tronde.access.log
state: touch
owner: root
group: root
mode: 0600
notify:
- reload php-fpm
- name: Copy dh_params.pem to target node
copy:
src: files/dh_params.pem
dest: /etc/nginx/dh_params.pem
owner: root
group: root
mode: 0644
notify:
- reload php-fpm
- name: Copy nginx virtual host to target node
copy:
src: files/my-it-brain.vhost
dest: /etc/nginx/sites-available/my-it-brain
owner: root
group: root
mode: 0644
backup: yes
- name: Create symbolic link in sites-enabled
file:
src: /etc/nginx/sites-available/my-it-brain
dest: /etc/nginx/sites-enabled/my-it-brain
state: link
owner: root
group: root
mode: 0777
notify:
- reload nginx
- name: Copy database dump file
copy:
src: files/db_dump.sql.bz2
dest: /tmp
- name: Restore database
mysql_db:
name: db_my_it_brain
state: import
target: /tmp/db_dump.sql.bz2
notify:
- reload nginx
- name: Create database user for blog
mysql_user:
name: "{{ DBUSER }}"
password: "{{ DBPASS }}"
priv: 'db_my_it_brain.*:ALL'
state: present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment