|
1 | 1 | ---
|
2 | 2 |
|
| 3 | +- name: check if secrets are properly set |
| 4 | + fail: |
| 5 | + failed_when: not {{ secret }} |
| 6 | + loop_control: |
| 7 | + loop_var: secret |
| 8 | + with_items: |
| 9 | + - gh_bot_secrets.envs.port |
| 10 | + - gh_bot_secrets.envs.travis_token |
| 11 | + - gh_bot_secrets.envs.github_token |
| 12 | + - gh_bot_secrets.envs.github_webhook_secret |
| 13 | + - gh_bot_secrets.envs.login_credentials |
| 14 | + - gh_bot_secrets.envs.jenkins_api_credentials |
| 15 | + - gh_bot_secrets.envs.jenkins_job_citgm |
| 16 | + - gh_bot_secrets.envs.jenkins_build_token_citgm |
| 17 | + - gh_bot_secrets.envs.jenkins_job_node |
| 18 | + - gh_bot_secrets.envs.jenkins_build_token_node |
| 19 | + - gh_bot_secrets.conf.github_deploy_webhook_secret |
| 20 | + |
| 21 | +- name: Get IP addresses of jenkins-workspace machines |
| 22 | + no_log: true |
| 23 | + set_fact: |
| 24 | + jenkins_workspace_ips: "{{ jenkins_workspace_ips | default([]) + [item.value.ansible_host | string] }}" |
| 25 | + when: "item.value.alias is defined and item.value.alias is match('jenkins-workspace.*')" |
| 26 | + with_dict: "{{ hostvars }}" |
| 27 | + |
3 | 28 | - name: Bootstrap | Install baseline packages
|
4 | 29 | package:
|
5 | 30 | name: "{{ package }}"
|
|
9 | 34 | with_items: "{{ base_packages }}"
|
10 | 35 |
|
11 | 36 | - name: Bootstrap | Add nodesource signing key
|
12 |
| - apt_key: |
13 |
| - url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key |
14 |
| - state: present |
| 37 | + ansible.builtin.get_url: |
| 38 | + dest: /etc/apt/keyrings/nodesource-repo.gpg.asc |
| 39 | + url: https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key |
15 | 40 |
|
16 | 41 | - name: Bootstrap | Add nodesource repo
|
17 | 42 | apt_repository:
|
18 |
| - repo: deb https://deb.nodesource.com/node_14.x jessie main |
| 43 | + repo: deb [arch=amd64 signed-by=/etc/apt/keyrings/nodesource-repo.gpg.asc] https://deb.nodesource.com/node_20.x nodistro main |
19 | 44 | state: present
|
20 | 45 |
|
21 | 46 | - name: Bootstrap | APT Update and upgrade
|
|
30 | 55 | loop_control:
|
31 | 56 | loop_var: package
|
32 | 57 | with_items: "{{ packages }}"
|
| 58 | + notify: |
| 59 | + - restart github-bot-deploy-webhook |
| 60 | + - restart github-bot |
33 | 61 |
|
34 | 62 | - name: Bootstrap | Enable time syncing
|
35 | 63 | service:
|
|
53 | 81 | template:
|
54 | 82 | src: "{{ role_path }}/templates/github-bot.service.j2"
|
55 | 83 | dest: /lib/systemd/system/github-bot.service
|
| 84 | + notify: |
| 85 | + - restart github-bot |
56 | 86 |
|
57 | 87 | - name: Init | Generate and copy systemd EnvironmentFile
|
58 | 88 | template:
|
59 | 89 | src: "{{ role_path }}/templates/environment-file.j2"
|
60 | 90 | dest: "/home/{{ server_user }}/environment/github-bot"
|
| 91 | + notify: |
| 92 | + - restart github-bot-deploy-webhook |
| 93 | + - restart github-bot |
61 | 94 |
|
62 | 95 | - name: Init | Clone github-bot repo
|
63 | 96 | become: yes
|
64 | 97 | become_user: "{{ server_user }}"
|
65 | 98 | git:
|
66 | 99 | repo: https://github.com/nodejs/github-bot.git
|
67 | 100 | dest: "/home/{{ server_user }}/github-bot"
|
| 101 | + notify: |
| 102 | + - restart github-bot |
68 | 103 |
|
69 | 104 | - name: Init | Install npm dependencies
|
70 | 105 | become: yes
|
71 | 106 | become_user: "{{ server_user }}"
|
72 | 107 | npm:
|
73 | 108 | path: "/home/{{ server_user }}/github-bot"
|
74 | 109 | production: yes
|
| 110 | + notify: |
| 111 | + - restart github-bot |
75 | 112 |
|
76 | 113 | - name: Init | Start github-bot
|
77 | 114 | service:
|
|
83 | 120 | npm:
|
84 | 121 | name: github-webhook
|
85 | 122 | global: yes
|
| 123 | + notify: |
| 124 | + - restart github-bot-deploy-webhook |
86 | 125 |
|
87 | 126 | - name: Deploy Webhook | Copy config
|
88 | 127 | template:
|
89 | 128 | src: "{{ role_path }}/templates/github-bot-deploy-webhook.json.j2"
|
90 | 129 | dest: "/home/{{ server_user }}/config/github-bot-deploy-webhook.json"
|
| 130 | + notify: |
| 131 | + - restart github-bot-deploy-webhook |
91 | 132 |
|
92 | 133 | - name: Deploy Webhook | Copy deploy script
|
93 | 134 | template:
|
94 | 135 | src: "{{ role_path }}/templates/deploy-github-bot.sh.j2"
|
95 | 136 | dest: "/home/{{ server_user }}/bin/deploy-github-bot.sh"
|
96 | 137 | mode: 0755
|
97 | 138 | owner: "{{ server_user }}"
|
| 139 | + notify: |
| 140 | + - restart github-bot-deploy-webhook |
98 | 141 |
|
99 | 142 | - name: Deploy Webhook | Generate and copy service script
|
100 | 143 | template:
|
101 | 144 | src: "{{ role_path }}/templates/github-bot-deploy-webhook.service.j2"
|
102 | 145 | dest: /lib/systemd/system/github-bot-deploy-webhook.service
|
| 146 | + notify: |
| 147 | + - restart github-bot-deploy-webhook |
103 | 148 |
|
104 | 149 | - name: Deploy Webhook | Start service
|
105 | 150 | service:
|
106 | 151 | name: github-bot-deploy-webhook
|
107 | 152 | state: started
|
108 | 153 | enabled: yes
|
| 154 | + notify: |
| 155 | + - restart github-bot-deploy-webhook |
109 | 156 |
|
110 | 157 | - name: Deploy Webhook | Allow user to restart github-bot
|
111 | 158 | lineinfile:
|
|
0 commit comments