diff options
-rw-r--r-- | ansible/playbooks/gitea.yml | 13 | ||||
-rw-r--r-- | ansible/roles/gitea/defaults/main.yml | 3 | ||||
-rw-r--r-- | ansible/roles/gitea/tasks/deploy_gitea.yml | 38 | ||||
-rw-r--r-- | ansible/roles/gitea/tasks/main.yml | 4 |
4 files changed, 58 insertions, 0 deletions
diff --git a/ansible/playbooks/gitea.yml b/ansible/playbooks/gitea.yml new file mode 100644 index 0000000..0f7a753 --- /dev/null +++ b/ansible/playbooks/gitea.yml @@ -0,0 +1,13 @@ +--- +- name: Deploy Gitea Service + hosts: tag_docker + become: true + + pre_tasks: + - name: Ensure Docker is installed + ansible.builtin.include_role: + name: docker + + roles: + - role: gitea +... diff --git a/ansible/roles/gitea/defaults/main.yml b/ansible/roles/gitea/defaults/main.yml new file mode 100644 index 0000000..acb1cb5 --- /dev/null +++ b/ansible/roles/gitea/defaults/main.yml @@ -0,0 +1,3 @@ +--- +gitea_root_dir: /opt/gitea +... diff --git a/ansible/roles/gitea/tasks/deploy_gitea.yml b/ansible/roles/gitea/tasks/deploy_gitea.yml new file mode 100644 index 0000000..4390689 --- /dev/null +++ b/ansible/roles/gitea/tasks/deploy_gitea.yml @@ -0,0 +1,38 @@ +--- +- name: Gather the package facts + ansible.builtin.package_facts: + manager: auto + +- name: Verify Docker and compose are available + ansible.builtin.assert: + that: + - "'docker-ce' in ansible_facts.packages" + - "'docker-compose-plugin' in ansible_facts.packages" + fail_msg: "Docker and compose plugin are not installed" + +- name: Create Gitea directories + ansible.builtin.file: + path: "{{ gitea_root_dir }}" + state: directory + mode: '0755' + +- name: Deploy Gitea stack using compose v2 + community.docker.docker_compose_v2: + project_src: "{{ playbook_dir }}/../../docker/compose/gitea" + state: present + pull: "policy" + recreate: always + +- name: Verify that gitea and db services are running + ansible.builtin.assert: + that: + - gitea_container.State == 'running' + - db_container.State == 'running' + vars: + gitea_container: >- + {{ output.containers | selectattr("Service", "equalto", "gitea") | first }} + db_container: >- + {{ output.containers | selectattr("Service", "equalto", "db") | first }} + + +... diff --git a/ansible/roles/gitea/tasks/main.yml b/ansible/roles/gitea/tasks/main.yml new file mode 100644 index 0000000..25b2e71 --- /dev/null +++ b/ansible/roles/gitea/tasks/main.yml @@ -0,0 +1,4 @@ +--- +- name: Deploy Gitea container and it's db + ansible.builtin.include_tasks: deploy_gitea.yml +... |