debian-forge-composer/templates/packer/ansible/roles/common/tasks/worker-initialization-service.yml
Ondřej Budai 9d0ae3bc1f packer: add initialization scripts
The worker needs quite a lot of configuration involving secrets. Baking them
in the AMI is just awful so we need to fetch them during the instance startup.

Previously, this was all done using cloud-init. This makes the cloud-init
config huge and it is also very hard to test.

This commit moves all the configuration scripts into the image itself.
Cloud-init still needs to be used to push the secret variables into the
instance. The configuration scripts are run after cloud-init. They pick up
yhe secrets and initialize the worker correctly.

These scripts were adopted from
75b752a1c0
(private repository).

During the adoption, some changes has to be applied to make shellcheck happy.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-01-04 16:17:59 +01:00

26 lines
764 B
YAML

---
- name: Copy worker initialization service
copy:
src: "{{ playbook_dir }}/roles/common/files/worker-initialization.service"
dest: /etc/systemd/system/
- name: Enable worker initialization service
systemd:
name: worker-initialization.service
enabled: yes
daemon_reload: yes # make sure the new service is loaded before enabling it
- name: Create a directory for initialization scripts
file:
path: /usr/local/libexec/worker-initialization-scripts
state: directory
- name: Copy scripts used by the initialization service
copy:
src: "{{ item }}"
dest: /usr/local/libexec/worker-initialization-scripts
mode: preserve
with_fileglob:
- "{{ playbook_dir }}/roles/common/files/worker-initialization-scripts/*"