From 9bb62ca0d8081e919fe79763abf330400832c6d0 Mon Sep 17 00:00:00 2001 From: Dominique Quatravaux Date: Sat, 6 Nov 2021 20:38:10 +0100 Subject: [PATCH] [refactor] Off with `git_current_branch` variable Use instead - `awx_playbook_branch` for `awx-instance` role, - `images_build_branch` for `wordpress-openshift-namespace` role. --- ansible/roles/awx-instance/tasks/main.yml | 7 +------ .../roles/wordpress-openshift-namespace/defaults/main.yml | 3 ++- .../roles/wordpress-openshift-namespace/tasks/images.yml | 4 +--- ansible/wpsible | 6 ------ 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/ansible/roles/awx-instance/tasks/main.yml b/ansible/roles/awx-instance/tasks/main.yml index fa40ecff5..1d276a45a 100644 --- a/ansible/roles/awx-instance/tasks/main.yml +++ b/ansible/roles/awx-instance/tasks/main.yml @@ -97,13 +97,8 @@ prj.organization = org prj.scm_type = "git" prj.scm_url = "{{ awx_project_github_url }}" - prj.scm_branch = "{{ _awx_playbook_branch }}" + prj.scm_branch = "{{ awx_playbook_branch }}" prj.scm_update_on_launch = True - vars: - _awx_playbook_branch: >- - {{ awx_playbook_branch | default( - "master" if awx_is_production else git_current_branch) - }} - import_tasks: container-group.yml tags: awx diff --git a/ansible/roles/wordpress-openshift-namespace/defaults/main.yml b/ansible/roles/wordpress-openshift-namespace/defaults/main.yml index 338d9a115..27539a585 100644 --- a/ansible/roles/wordpress-openshift-namespace/defaults/main.yml +++ b/ansible/roles/wordpress-openshift-namespace/defaults/main.yml @@ -1,2 +1,3 @@ --- -# defaults file for wordpress-openshift-namespace +# defaults file for wordpress-openshift-namespace role +images_build_branch: master diff --git a/ansible/roles/wordpress-openshift-namespace/tasks/images.yml b/ansible/roles/wordpress-openshift-namespace/tasks/images.yml index 6000eae25..b8c06b4bf 100644 --- a/ansible/roles/wordpress-openshift-namespace/tasks/images.yml +++ b/ansible/roles/wordpress-openshift-namespace/tasks/images.yml @@ -24,7 +24,7 @@ git: repository: "{{ wp_ops_git_uri }}" path: "{{ item.git_path }}" - ref: "{{ git_current_branch }}" + ref: "{{ images_build_branch }}" strategy: "{{ item.strategy | default({}) }}" with_items: - name: "{{ wp_base_image_name }}" @@ -42,9 +42,7 @@ --s3-bucket-name={{ build.s3_assets.bucket_name }} --s3-key-id={{ build.s3_assets.key_id }} --s3-secret={{ build.s3_assets.secret | eyaml(eyaml_keys) }} - {%if images_build_branch is defined %} --manifest-url=https://raw.githubusercontent.com/epfl-si/wp-ops/{{ images_build_branch }}/ansible/roles/wordpress-instance/tasks/plugins.yml - {%endif%} - name: "{{ httpd_image_name }}" git_path: docker/httpd from: "{{ wp_base_image_name }}" diff --git a/ansible/wpsible b/ansible/wpsible index ca691374d..94ba22f15 100755 --- a/ansible/wpsible +++ b/ansible/wpsible @@ -21,12 +21,6 @@ cd "$(dirname "$0")"; cd "$(/bin/pwd)" playbook_flags="-e play_update=yes -e play_backup=yes -e play_create_or_restore=yes" ansible_flags="-e @roles/wordpress-instance/vars/main.yml" -git_current_branch="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)" -case "$git_current_branch" in - "") : ;; - *) playbook_flags="$playbook_flags -e git_current_branch=$git_current_branch" ;; -esac - warn () { if [ -n "$1" ]; then echo "$@" >&2