Last active
February 8, 2019 05:59
-
-
Save DanHulton/c4e751b572b5d2516d6e6a02ee6b90be to your computer and use it in GitHub Desktop.
Ansible playbook to install Bookstack to an ubuntu 18.04 host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Change
bookstack_domain
to set up Bookstack on a different URL.