Skip to content

Instantly share code, notes, and snippets.

@DanHulton
Last active February 8, 2019 05:59
Show Gist options
  • Save DanHulton/c4e751b572b5d2516d6e6a02ee6b90be to your computer and use it in GitHub Desktop.
Save DanHulton/c4e751b572b5d2516d6e6a02ee6b90be to your computer and use it in GitHub Desktop.
Ansible playbook to install Bookstack to an ubuntu 18.04 host
---
- hosts: all
vars:
ansible_python_interpreter: /usr/bin/python3
bookstack_domain: bookstack.local
mysql_root_password: abc123
tasks:
- name: Set MySQL root password before installing
debconf: name='mysql-server' question='mysql-server/root_password' value='{{ mysql_root_password | quote }}' vtype='password'
become: yes
- name: Confirm MySQL root password before installing
debconf: name='mysql-server' question='mysql-server/root_password_again' value='{{ mysql_root_password | quote }}' vtype='password'
become: yes
- name: Create MySQL client config
copy:
dest: "/root/.my.cnf"
content: |
[client]
user=root
password={{ mysql_root_password }}
become: yes
- name: Install pip
apt:
name: python3-pip
state: present
update_cache: yes
become: yes
- name: Install PyMySQL
pip:
name: PyMySQL
register: what
become: yes
- name: Download BookStack
get_url:
url: "https://raw.githubusercontent.com/BookStackApp/devops/master/scripts/installation-ubuntu-18.04.sh"
dest: /home/ubuntu/installation-ubuntu-18.04.sh
mode: 0700
- name: Install BookStack
shell: "/home/ubuntu/installation-ubuntu-18.04.sh {{ bookstack_domain }}"
args:
creates: /home/ubuntu/bookstack-installed-DO-NOT-REMOVE
become: yes
- name: Allow external MySQL connections (1/2) <<<Insecure, only use for local>>>
lineinfile:
path: /etc/mysql/mysql.conf.d/mysqld.cnf
regexp: '^skip-external-locking'
line: "# skip-external-locking"
become: yes
- name: Allow external MySQL connections (2/2) <<<Insecure, only use for local>>>
lineinfile:
path: /etc/mysql/mysql.conf.d/mysqld.cnf
regexp: '^bind-address'
line: "# bind-address"
become: yes
when: bookstack_domain == 'bookstack.local'
- name: Add remote MySQL user <<<Insecure, only use for local>>>
mysql_user:
login_user: root
login_password: "{{ mysql_root_password }}"
name: remote
password: remote
priv: '*.*:ALL'
host: "%"
state: present
when: bookstack_domain == 'bookstack.local'
become: yes
- name: Restart MySQL
service:
name: mysql
state: restarted
become: yes
when: bookstack_domain == 'bookstack.local'
@DanHulton
Copy link
Author

Change bookstack_domain to set up Bookstack on a different URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment