summaryrefslogtreecommitdiff
path: root/roles/mkdocs/main.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/mkdocs/main.yml')
-rw-r--r--roles/mkdocs/main.yml119
1 files changed, 119 insertions, 0 deletions
diff --git a/roles/mkdocs/main.yml b/roles/mkdocs/main.yml
new file mode 100644
index 0000000..78a437e
--- /dev/null
+++ b/roles/mkdocs/main.yml
@@ -0,0 +1,119 @@
+---
+- name: Container Setup
+
+ vars:
+ lxc_base: ansible-alpine3.11
+ lxc_name: mkdocs
+
+ import_playbook: ../common/tasks/lxc.yml
+
+- name: Installing MkDocs
+ hosts: mkdocs
+
+ vars_files:
+ - ../variables.yml
+
+ tasks:
+
+ - name: Ensuring group exists
+ group:
+ name: "{{ mkdocs_user }}"
+ state: present
+
+ - name: Creating user and making home directory
+ user:
+ system: yes
+ state: present
+ name: "{{ mkdocs_user }}"
+ groups: "{{ mkdocs_user }}"
+ home: "{{ mkdocs_home }}"
+
+ - name: Installing the required dependencies
+ apk:
+ state: present
+ update_cache: yes
+ name:
+ - sudo
+ - git
+ - supervisor
+
+ - block:
+
+ - name: Setting up python virtual environment
+ shell: python3 -m venv .
+ args:
+ chdir: "{{ mkdocs_home }}"
+ creates: bin/activate
+
+ - name: Installing application
+ shell: |
+ . bin/activate
+ pip install git+https://github.com/mkdocs/mkdocs@{{ mkdocs_version }}
+ pip install -Iv mkdocs-material=={{ mkdocs_material_version }}
+ args:
+ chdir: "{{ mkdocs_home }}"
+ creates: bin/mkdocs
+
+ - name: Copying config file
+ copy:
+ src: mkdocs.yml
+ dest: "{{ mkdocs_home }}"
+ mode: '0644'
+ register: mkdocsConfig
+
+ - name: Creating document directory
+ file:
+ path: "{{ mkdocs_home }}/docs"
+ state: directory
+
+ - name: Copying index file
+ copy:
+ src: index.md
+ dest: "{{ mkdocs_home }}/docs"
+ mode: '0644'
+
+ become: true
+ become_user: "{{ mkdocs_user }}"
+
+ - name: Copying supervisord config file
+ copy:
+ src: supervisord.conf
+ dest: /etc/supervisord.conf
+ mode: '0644'
+ register: supervisorConfig
+
+ - name: Ensuring supervisord has been started and enabled
+ service:
+ name: supervisord
+ state: started
+ enabled: yes
+
+ - name: Waiting for supervisor to become active
+ wait_for:
+ port: 9100
+
+ - name: Restarting supervisord due to config change
+ service:
+ name: supervisord
+ state: restarted
+ when: supervisorConfig.changed
+
+ - name: Ensuring application has been started
+ supervisorctl:
+ name: mkdocs
+ state: started
+
+ - name: Waiting for application to become active
+ wait_for:
+ port: 8000
+
+ - name: Restarting application due to config change
+ supervisorctl:
+ name: mkdocs
+ state: restarted
+ when: mkdocsConfig.changed
+
+ - name: Testing if webpage exists
+ uri:
+ url: http://0.0.0.0:8000
+ return_content: yes