2023-02-06 20:22:21 +00:00
|
|
|
---
|
|
|
|
- name: Ensure ghost group is created
|
|
|
|
ansible.builtin.group:
|
|
|
|
name: "{{ ghost_user_group }}"
|
|
|
|
state: present
|
|
|
|
system: true
|
|
|
|
|
|
|
|
- name: Ensure ghost user is created
|
|
|
|
ansible.builtin.user:
|
|
|
|
name: "{{ ghost_user }}"
|
|
|
|
groups:
|
|
|
|
- "{{ ghost_user_group }}"
|
|
|
|
append: true
|
|
|
|
state: present
|
|
|
|
system: true
|
|
|
|
|
|
|
|
- name: Ensure host paths for docker volumes exist for ghost
|
|
|
|
ansible.builtin.file:
|
2023-10-07 14:16:53 +00:00
|
|
|
path: "{{ item.path }}"
|
2023-02-06 20:22:21 +00:00
|
|
|
state: directory
|
|
|
|
mode: "0750"
|
2023-10-07 14:16:53 +00:00
|
|
|
owner: "{{ item.owner | default(ghost_user) }}"
|
|
|
|
group: "{{ item.group | default(ghost_user_group) }}"
|
2023-02-06 20:22:21 +00:00
|
|
|
loop:
|
2023-10-07 14:16:53 +00:00
|
|
|
- path: "{{ ghost_base_path }}"
|
|
|
|
- path: "{{ ghost_data_path }}"
|
|
|
|
owner: "1000"
|
|
|
|
- path: "{{ ghost_config_path }}"
|
2023-02-06 20:22:21 +00:00
|
|
|
|
|
|
|
- name: Ensure ghost configuration file is templated
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "ghost.env.j2"
|
|
|
|
dest: "{{ ghost_config_file }}"
|
|
|
|
owner: "{{ ghost_user }}"
|
|
|
|
group: "{{ ghost_user_group }}"
|
|
|
|
mode: "0644"
|
|
|
|
|
|
|
|
- name: Ensure ghost container image is present on host
|
|
|
|
community.docker.docker_image:
|
|
|
|
name: "{{ ghost_container_image }}"
|
|
|
|
state: present
|
|
|
|
source: pull
|
|
|
|
force_source: "{{ ghost_container_image_tag is defined }}"
|
|
|
|
|
2023-10-07 14:16:53 +00:00
|
|
|
- name: Ensure ghost container '{{ ghost_container_name }}' is {{ ghost_container_state }}
|
2023-02-06 20:22:21 +00:00
|
|
|
community.docker.docker_container:
|
|
|
|
name: "{{ ghost_container_name }}"
|
|
|
|
image: "{{ ghost_container_image }}"
|
|
|
|
ports: "{{ ghost_container_ports | default(omit, true) }}"
|
|
|
|
labels: "{{ ghost_container_labels }}"
|
|
|
|
volumes: "{{ ghost_container_volumes }}"
|
|
|
|
env_file: "{{ ghost_config_file }}"
|
|
|
|
etc_hosts: "{{ ghost_container_etc_hosts | default(omit, true) }}"
|
|
|
|
networks: "{{ ghost_container_networks | default(omit, true) }}"
|
|
|
|
purge_networks: "{{ ghost_container_purge_networks | default(omit, true) }}"
|
|
|
|
restart_policy: "{{ ghost_container_restart_policy }}"
|
2023-10-07 14:16:53 +00:00
|
|
|
state: "{{ ghost_container_state }}"
|