From 1a564ebdd597b16ba15b5a8882097cd080a04e39 Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen@paragon-es.de> Date: Thu, 10 Jan 2019 17:40:49 +0100 Subject: [PATCH] Implement new mode gitextra for collecting config --- tasks/collect_config/commit/git.yml | 2 +- tasks/collect_config/commit/gitextra.yml | 28 +++++++++++++++++++++++ tasks/collect_config/finish/gitextra.yml | 18 +++++++++++++++ tasks/collect_config/main.yml | 6 ++--- tasks/collect_config/prepare/gitextra.yml | 25 ++++++++++++++++++++ 5 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 tasks/collect_config/commit/gitextra.yml create mode 100644 tasks/collect_config/finish/gitextra.yml create mode 100644 tasks/collect_config/prepare/gitextra.yml diff --git a/tasks/collect_config/commit/git.yml b/tasks/collect_config/commit/git.yml index a48a9d7..e7d473f 100644 --- a/tasks/collect_config/commit/git.yml +++ b/tasks/collect_config/commit/git.yml @@ -1,5 +1,5 @@ --- -# file: roles/drupal/tasks/config_collect/commit/gitcomposer.yml +# file: roles/drupal/tasks/config_collect/commit/git.yml - block: diff --git a/tasks/collect_config/commit/gitextra.yml b/tasks/collect_config/commit/gitextra.yml new file mode 100644 index 0000000..a06a159 --- /dev/null +++ b/tasks/collect_config/commit/gitextra.yml @@ -0,0 +1,28 @@ +--- +# file: roles/drupal/tasks/config_collect/commit/gitextra.yml + +- block: + + - name: "Check Git Status" + shell: 'git status -s' + args: + chdir: '{{ webRoot }}/{{ collect_config_key }}' + become: false + register: git_status + + - block: + + - name: "Add and commit files" + shell: 'git {{ item }}' + args: + chdir: '{{ webRoot }}/{{ collect_config_key }}' + become: false + with_items: + - 'add config/*' + - 'config user.email "deployment@lakedrops.com"' + - 'config user.name "Auto Config Export"' + - 'commit -am "[ci skip] Config change on server"' + + when: git_status.stdout != '' + + tags: 'deploy' diff --git a/tasks/collect_config/finish/gitextra.yml b/tasks/collect_config/finish/gitextra.yml new file mode 100644 index 0000000..39bc598 --- /dev/null +++ b/tasks/collect_config/finish/gitextra.yml @@ -0,0 +1,18 @@ +--- +# file: roles/drupal/tasks/config_collect/finish/gitextra.yml + +- block: + + - name: "Push" + shell: 'git push' + args: + chdir: '{{ webRoot }}/{{ collect_config_key }}' + become: false + when: git_status.stdout != '' + + - name: "Delete webroot working copy" + file: + path: '{{ webRoot }}' + state: absent + + tags: 'deploy' diff --git a/tasks/collect_config/main.yml b/tasks/collect_config/main.yml index 7920eaa..7aab579 100644 --- a/tasks/collect_config/main.yml +++ b/tasks/collect_config/main.yml @@ -6,11 +6,11 @@ - set_fact: version='{{ lookup('pipe','date +%Y-%m-%d-%H-%M-%S') }}' - set_fact: - webRoot='/tmp/ansible-cae-{{ drupal.jail.name }}-{{ version }}-gitflow' + webRoot='/tmp/ansible-cae-{{ drupal.id }}-{{ version }}-gitflow' - set_fact: - pathConfig='{{ webRoot }}/config/default/sync' + pathConfig='{{ webRoot }}/{{ collect_config_key|default("config") }}/default/sync' pathExport='{{ export_path }}' - pathWorking='/tmp/ansible-cae-{{ drupal.jail.name }}-{{ version }}' + pathWorking='/tmp/ansible-cae-{{ drupal.id }}-{{ version }}' collectConfig={{ drupal.src.collectConfig|default([]) }} - name: "Check if export path exists" diff --git a/tasks/collect_config/prepare/gitextra.yml b/tasks/collect_config/prepare/gitextra.yml new file mode 100644 index 0000000..775056c --- /dev/null +++ b/tasks/collect_config/prepare/gitextra.yml @@ -0,0 +1,25 @@ +--- +# file: roles/drupal/tasks/config_collect/prepare/gitextra.yml + +- block: + + - name: "Clone Git Repository" + git: + accept_hostkey: yes + repo: '{{ drupal.src.git.extrarepos[item] }}' + dest: '{{ webRoot }}/{{ item }}' + force: yes + version: '{{ drupal.src.git.branch|default(omit) }}' + become: false + with_items: '{{ drupal.src.git.extrarepos|default([]) }}' + when: collect_config_key == item + + - name: "Create Git Hook for commit message" + copy: + content: | + #!/bin/sh + echo "[ci skip]" >>$1 + dest: '{{ webRoot }}/{{ collect_config_key }}/.git/hooks/prepare-commit-msg' + mode: '0777' + + tags: 'deploy' -- GitLab