joelbirchler
2020-03-03 73a52a15ce4aefe711f0dd684cadb5cb2c52602d
ansible/configs/ansible-skylight/workloads.yml
@@ -1,18 +1,50 @@
---
- name: Clone private workloads
  hosts: localhost
  gather_facts: false
  run_once: true
  become: false
  pre_tasks:
    - include: workloads_cleanup.yml
  tasks:
    - name: Create and pull repo
      shell: |
        source_path=/tmp/{{ item.name }}-private-workload
        workload_path=$(pwd)/../../roles/{{ item.name }}-private-workload
        mkdir -p $source_path && cd $source_path
        git init
        git remote add origin {{ item.url }}
        git config core.sparseCheckout true
        echo "{{ item.path }}" >> .git/info/sparse-checkout
        git config core.sshCommand "ssh -i {{ item.ssh_key }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
        git pull --depth=1 origin master
        ln -s $source_path/{{ item.path }} $workload_path
      loop: "{{ private_workloads }}"
- name: Install workloads
  hosts: bastions
  gather_facts: false
  run_once: true
  become: false
  tasks:
    - name: Include private workloads
      include_role:
        name: "{{ item.tmp }}"
        name: "{{ item.name }}-private-workload"
      vars:
        ACTION:         "provision"
        workload_name:  "{{ item.name }}"
        git_remote_url: "{{ item.url }}"
        git_path:       "{{ item.path }}"
        git_ssh_key:    "{{ item.ssh_key }}"
      loop: "{{ private_workloads }}"
        git_ssh_key:    "{{ item.git_ssh_key }}"
      loop: "{{ private_workloads }}"
- name: Cleanup private workloads
  hosts: localhost
  gather_facts: false
  run_once: true
  become: false
  tasks:
    - include: workloads_cleanup.yml