xoxys.droneci_autoscaler/tasks/setup.yml

56 lines
1.7 KiB
YAML
Raw Normal View History

2020-09-30 19:56:00 +00:00
---
- name: Register working directory
set_fact:
__droneci_autoscaler_workdir: "{{ droneci_autoscaler_service_directory }}_{{ inst.name }}"
- name: Register SSH key
set_fact:
2020-09-30 22:29:49 +00:00
__droneci_autoscaler_sshkey: "{{ (inst.sshkey | default(droneci_autoscaler_sshkey)) | default('') }}"
2020-09-30 19:56:00 +00:00
- block:
- name: Ensure service directory exists
file:
path: "{{ __droneci_autoscaler_workdir }}"
state: directory
mode: 0755
- name: Deploy compose file to '{{ __droneci_autoscaler_workdir }}'
template:
src: "services/droneci_autoscaler_compose.yml.j2"
dest: "{{ __droneci_autoscaler_workdir }}/docker-compose.yml"
owner: root
group: root
mode: 0640
validate: "docker-compose -f %s config -q"
- name: Write SSH private key
copy:
2020-09-30 21:21:16 +00:00
content: "{{ __droneci_autoscaler_sshkey }}"
2020-09-30 19:56:00 +00:00
dest: "{{ __droneci_autoscaler_workdir }}/ssh_key"
mode: 0600
2020-09-30 22:33:03 +00:00
when: __droneci_autoscaler_sshkey | length > 0
2020-09-30 19:56:00 +00:00
no_log: True
2020-10-01 06:45:33 +00:00
- name: Generate SSH key pair
2020-09-30 19:56:00 +00:00
openssh_keypair:
path: "{{ __droneci_autoscaler_workdir }}/ssh_key"
type: ed25519
force: False
state: present
2020-10-01 06:45:33 +00:00
when: not __droneci_autoscaler_sshkey | length > 0
2020-09-30 19:56:00 +00:00
- name: Write userdata
template:
src: services/userdata.yml.j2
dest: "{{ __droneci_autoscaler_workdir }}/userdata.yml"
- name: Ensure scaler is up and running
docker_compose:
project_src: "{{ __droneci_autoscaler_workdir }}"
pull: yes
remove_orphans: yes
stopped: "{{ inst.service_stopped | default(droneci_autoscaler_service_stopped) }}"
state: present
become: True
become_user: root