From 209cc16465993913ab37d47e6f46c5fc4c8d1eed Mon Sep 17 00:00:00 2001 From: Sebastian Luna-Valero Date: Fri, 29 Nov 2024 10:57:45 +0100 Subject: [PATCH 1/5] update docker_compose task --- artifacts/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/artifacts/docker.yml b/artifacts/docker.yml index a67614d..b585ed8 100644 --- a/artifacts/docker.yml +++ b/artifacts/docker.yml @@ -23,6 +23,6 @@ version: "{{ git_version }}" - name: docker-compose up - docker_compose: + community.docker.docker_compose_v2: project_src: "/opt/docker_compose/{{ docker_compose_folder }}" state: present From 481b14c346b2d9d2e025878ecf57029806e0f92a Mon Sep 17 00:00:00 2001 From: Sebastian Luna-Valero Date: Tue, 3 Dec 2024 15:23:01 +0100 Subject: [PATCH 2/5] add first docker-galaxy artifact --- artifacts/docker-galaxy-01.yml | 67 ++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 artifacts/docker-galaxy-01.yml diff --git a/artifacts/docker-galaxy-01.yml b/artifacts/docker-galaxy-01.yml new file mode 100644 index 0000000..1e7e27e --- /dev/null +++ b/artifacts/docker-galaxy-01.yml @@ -0,0 +1,67 @@ +--- +- hosts: localhost + connection: local + vars: + docker_compose_folder: "{{ compose_folder | default('') }}" + git_version: "{{ repo_branch | default('master') }}" + roles: + - role: 'grycap.docker' + tasks: + - name: docker_compose_git is mandatory + ansible.builtin.fail: + msg: Please provide a git repository to clone and perform a docker-compose up + when: docker_compose_git is not defined or docker_compose_git == "" + + - name: Install git package + ansible.builtin.package: + name: git + state: present + ignore_errors: true + + - name: Clone docker-compose git repository + ansible.builtin.git: + repo: '{{ docker_compose_git }}' + dest: /opt/docker_compose + version: "{{ git_version }}" + + - name: Make sure .env file exists + ansible.builtin.file: + path: /opt/docker_compose/.env + state: touch + modification_time: preserve + access_time: preserve + + - name: Configure GALAXY_CONFIG_BRAND + ansible.builtin.lineinfile: + path: /opt/docker_compose/.env + regexp: '^GALAXY_CONFIG_BRAND=' + line: GALAXY_CONFIG_BRAND=galaxy_config_brand + when: galaxy_config_brand is defined + + - name: Configure PROXY_PREFIX + ansible.builtin.lineinfile: + path: /opt/docker_compose/.env + regexp: '^PROXY_PREFIX=' + line: PROXY_PREFIX=proxy_prefix + when: proxy_prefix is defined + + - name: Configure NONUSE + ansible.builtin.lineinfile: + path: /opt/docker_compose/.env + regexp: '^NONUSE=' + line: NONUSE=nonuse + when: nonuse is defined + + - name: Configure GALAXY_CONFIG_ENABLE_MULLED_CONTAINERS + ansible.builtin.lineinfile: + path: /opt/docker_compose/.env + regexp: '^GALAXY_CONFIG_ENABLE_MULLED_CONTAINERS=' + line: GALAXY_CONFIG_ENABLE_MULLED_CONTAINERS=galaxy_config_enable_mulled_containers + when: galaxy_config_enable_mulled_containers is defined + + - name: docker-compose up + community.docker.docker_compose_v2: + project_src: "/opt/docker_compose/{{ docker_compose_folder }}" + state: present + env_files: + - "/opt/docker_compose/.env" From ce330b2474618c60170c66d454763ba497518a85 Mon Sep 17 00:00:00 2001 From: Sebastian Luna-Valero Date: Tue, 3 Dec 2024 15:44:18 +0100 Subject: [PATCH 3/5] ansible-lint --- artifacts/docker-galaxy-01.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/artifacts/docker-galaxy-01.yml b/artifacts/docker-galaxy-01.yml index 1e7e27e..3692180 100644 --- a/artifacts/docker-galaxy-01.yml +++ b/artifacts/docker-galaxy-01.yml @@ -30,6 +30,9 @@ state: touch modification_time: preserve access_time: preserve + owner: root + group: root + mode: '0644' - name: Configure GALAXY_CONFIG_BRAND ansible.builtin.lineinfile: From 494f2808488539b74f4a539333292857a4860e26 Mon Sep 17 00:00:00 2001 From: Sebastian Luna-Valero Date: Tue, 3 Dec 2024 15:51:16 +0100 Subject: [PATCH 4/5] variables --- artifacts/docker-galaxy-01.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/artifacts/docker-galaxy-01.yml b/artifacts/docker-galaxy-01.yml index 3692180..05795c1 100644 --- a/artifacts/docker-galaxy-01.yml +++ b/artifacts/docker-galaxy-01.yml @@ -38,28 +38,28 @@ ansible.builtin.lineinfile: path: /opt/docker_compose/.env regexp: '^GALAXY_CONFIG_BRAND=' - line: GALAXY_CONFIG_BRAND=galaxy_config_brand + line: GALAXY_CONFIG_BRAND='{{ galaxy_config_brand }}' when: galaxy_config_brand is defined - name: Configure PROXY_PREFIX ansible.builtin.lineinfile: path: /opt/docker_compose/.env regexp: '^PROXY_PREFIX=' - line: PROXY_PREFIX=proxy_prefix + line: PROXY_PREFIX='{{ proxy_prefix }}' when: proxy_prefix is defined - name: Configure NONUSE ansible.builtin.lineinfile: path: /opt/docker_compose/.env regexp: '^NONUSE=' - line: NONUSE=nonuse + line: NONUSE='{{ nonuse }}' when: nonuse is defined - name: Configure GALAXY_CONFIG_ENABLE_MULLED_CONTAINERS ansible.builtin.lineinfile: path: /opt/docker_compose/.env regexp: '^GALAXY_CONFIG_ENABLE_MULLED_CONTAINERS=' - line: GALAXY_CONFIG_ENABLE_MULLED_CONTAINERS=galaxy_config_enable_mulled_containers + line: GALAXY_CONFIG_ENABLE_MULLED_CONTAINERS='{{ galaxy_config_enable_mulled_containers }}' when: galaxy_config_enable_mulled_containers is defined - name: docker-compose up From 23f9cdaf3c24603d679f785aeacf6fd649747861 Mon Sep 17 00:00:00 2001 From: Sebastian Luna-Valero Date: Tue, 3 Dec 2024 16:03:39 +0100 Subject: [PATCH 5/5] skip when vars are empty --- artifacts/docker-galaxy-01.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/artifacts/docker-galaxy-01.yml b/artifacts/docker-galaxy-01.yml index 05795c1..17f07aa 100644 --- a/artifacts/docker-galaxy-01.yml +++ b/artifacts/docker-galaxy-01.yml @@ -39,28 +39,28 @@ path: /opt/docker_compose/.env regexp: '^GALAXY_CONFIG_BRAND=' line: GALAXY_CONFIG_BRAND='{{ galaxy_config_brand }}' - when: galaxy_config_brand is defined + when: galaxy_config_brand is defined and galaxy_config_brand != "" - name: Configure PROXY_PREFIX ansible.builtin.lineinfile: path: /opt/docker_compose/.env regexp: '^PROXY_PREFIX=' line: PROXY_PREFIX='{{ proxy_prefix }}' - when: proxy_prefix is defined + when: proxy_prefix is defined and proxy_prefix != "" - name: Configure NONUSE ansible.builtin.lineinfile: path: /opt/docker_compose/.env regexp: '^NONUSE=' line: NONUSE='{{ nonuse }}' - when: nonuse is defined + when: nonuse is defined and nonuse != "" - name: Configure GALAXY_CONFIG_ENABLE_MULLED_CONTAINERS ansible.builtin.lineinfile: path: /opt/docker_compose/.env regexp: '^GALAXY_CONFIG_ENABLE_MULLED_CONTAINERS=' line: GALAXY_CONFIG_ENABLE_MULLED_CONTAINERS='{{ galaxy_config_enable_mulled_containers }}' - when: galaxy_config_enable_mulled_containers is defined + when: galaxy_config_enable_mulled_containers is defined and galaxy_config_enable_mulled_containers != "" - name: docker-compose up community.docker.docker_compose_v2: