Commit ab523cea by arbabnazar

using YAML syntax for ansible tasks

parent 92acf889
...@@ -17,7 +17,10 @@ ...@@ -17,7 +17,10 @@
# require in our default configuration. # require in our default configuration.
# #
# #
- name: set git fetch.prune to ignore deleted remote refs # Rewrite this task using the ansible git-config module once we'll migrate to Ansible 2.x
# https://docs.ansible.com/ansible/git_config_module.html#git-config
#
- name: Set git fetch.prune to ignore deleted remote refs
shell: git config --global fetch.prune true shell: git config --global fetch.prune true
become_user: "{{ repo_owner }}" become_user: "{{ repo_owner }}"
when: GIT_REPOS is defined when: GIT_REPOS is defined
...@@ -25,28 +28,29 @@ ...@@ -25,28 +28,29 @@
- install - install
- install:code - install:code
- name: validate git protocol - name: Validate git protocol
fail: msg='GIT_REPOS.PROTOCOL must be "https" or "ssh"' fail:
msg: '{{ GIT_REPOS.PROTOCOL }} must be "https" or "ssh"'
when: (item.PROTOCOL != "https") and (item.PROTOCOL != "ssh") and GIT_REPOS is defined when: (item.PROTOCOL != "https") and (item.PROTOCOL != "ssh") and GIT_REPOS is defined
with_items: GIT_REPOS with_items: "{{ GIT_REPOS }}"
tags: tags:
- install - install
- install:code - install:code
- name: install read-only ssh key - name: Install read-only ssh key
copy: copy:
dest: "{{ git_home }}/.ssh/{{ item.REPO }}" dest: "{{ git_home }}/.ssh/{{ item.REPO }}"
content: "{{ item.SSH_KEY }}" content: "{{ item.SSH_KEY }}"
owner: "{{ repo_owner }}" owner: "{{ repo_owner }}"
group: "{{ repo_group }}" group: "{{ repo_group }}"
mode: 0600 mode: "0600"
when: item.PROTOCOL == "ssh" and GIT_REPOS is defined when: item.PROTOCOL == "ssh" and GIT_REPOS is defined
with_items: GIT_REPOS with_items: "{{ GIT_REPOS }}"
tags: tags:
- install - install
- install:code - install:code
- name: checkout code over ssh - name: Checkout code over ssh
git_2_0_1: git_2_0_1:
repo: "git@{{ item.DOMAIN }}:{{ item.PATH }}/{{ item.REPO }}" repo: "git@{{ item.DOMAIN }}:{{ item.PATH }}/{{ item.REPO }}"
dest: "{{ item.DESTINATION }}" dest: "{{ item.DESTINATION }}"
...@@ -56,12 +60,12 @@ ...@@ -56,12 +60,12 @@
become_user: "{{ repo_owner }}" become_user: "{{ repo_owner }}"
register: code_checkout register: code_checkout
when: item.PROTOCOL == "ssh" and GIT_REPOS is defined when: item.PROTOCOL == "ssh" and GIT_REPOS is defined
with_items: GIT_REPOS with_items: "{{ GIT_REPOS }}"
tags: tags:
- install - install
- install:code - install:code
- name: checkout code over https - name: Checkout code over https
git_2_0_1: git_2_0_1:
repo: "https://{{ item.DOMAIN }}/{{ item.PATH }}/{{ item.REPO }}" repo: "https://{{ item.DOMAIN }}/{{ item.PATH }}/{{ item.REPO }}"
dest: "{{ item.DESTINATION }}" dest: "{{ item.DESTINATION }}"
...@@ -69,17 +73,17 @@ ...@@ -69,17 +73,17 @@
become_user: "{{ repo_owner }}" become_user: "{{ repo_owner }}"
register: code_checkout register: code_checkout
when: item.PROTOCOL == "https" and GIT_REPOS is defined when: item.PROTOCOL == "https" and GIT_REPOS is defined
with_items: GIT_REPOS with_items: "{{ GIT_REPOS }}"
tags: tags:
- install - install
- install:code - install:code
- name: remove read-only ssh key - name: Remove read-only ssh key
file: file:
dest: "{{ git_home }}/.ssh/{{ item.REPO }}" dest: "{{ git_home }}/.ssh/{{ item.REPO }}"
state: absent state: absent
when: item.PROTOCOL == "ssh" and GIT_REPOS is defined when: item.PROTOCOL == "ssh" and GIT_REPOS is defined
with_items: GIT_REPOS with_items: "{{ GIT_REPOS }}"
tags: tags:
- install - install
- install:code - install:code
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment