SF initial configurator | a26c41e | 2022-10-06 13:33:13 +0300 | [diff] [blame] | 1 | # This file is managed by ansible, do not edit directly |
| 2 | --- |
| 3 | - name: Discover path of config repository |
| 4 | command: git rev-parse --show-toplevel |
| 5 | register: config_path |
| 6 | |
| 7 | - name: Get last change sha |
| 8 | command: "git --git-dir={{ config_path.stdout }}/.git log -n1 --pretty=format:'%h' --no-merges" |
| 9 | register: git_log |
| 10 | |
| 11 | - name: Get last change on resources sha |
| 12 | command: "git --git-dir={{ config_path.stdout }}/.git log -n1 --pretty=format:'%h' --no-merges -- resources zuul" |
| 13 | register: git_log_resources |
| 14 | |
| 15 | - block: |
| 16 | - name: Create SSH private key tempfile |
| 17 | tempfile: |
| 18 | state: file |
| 19 | register: ssh_private_key_tmp |
| 20 | |
| 21 | - name: Create SSH private key from secret |
| 22 | copy: |
| 23 | content: "{{ site_tenant_update.ssh_private_key }}" |
| 24 | dest: "{{ ssh_private_key_tmp.path }}" |
| 25 | mode: '0600' |
| 26 | |
| 27 | - name: Add zuul ssh key |
| 28 | command: "ssh-add {{ ssh_private_key_tmp.path }}" |
| 29 | |
| 30 | - name: Remove SSH private key from disk |
| 31 | command: "shred {{ ssh_private_key_tmp.path }}" |
| 32 | |
| 33 | - name: Add site_tenant_update server to known hosts |
| 34 | known_hosts: |
| 35 | name: "{{ site_tenant_update.fqdn }}" |
| 36 | key: "{{ site_tenant_update.ssh_known_hosts }}" |
| 37 | |
| 38 | - name: Run tenant_update |
| 39 | command: "ssh root@{{ site_tenant_update.fqdn }} tenant_update" |
| 40 | when: git_log_resources.stdout == git_log.stdout |