56 lines
1.7 KiB
YAML
56 lines
1.7 KiB
YAML
|
---
|
||
|
- name: Register working directory
|
||
|
set_fact:
|
||
|
__droneci_autoscaler_workdir: "{{ droneci_autoscaler_service_directory }}_{{ inst.name }}"
|
||
|
|
||
|
- name: Register SSH key
|
||
|
set_fact:
|
||
|
__droneci_autoscaler_sshkey: "{{ inst.ssh_key | default(droneci_autoscaler_sshkey) | default(False) }}"
|
||
|
|
||
|
- 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:
|
||
|
content: "{{ item }}"
|
||
|
dest: "{{ __droneci_autoscaler_workdir }}/ssh_key"
|
||
|
mode: 0600
|
||
|
loop: "{{ inst.ssh_key | default(droneci_autoscaler_sshkey) }}"
|
||
|
when: __droneci_autoscaler_sshkey
|
||
|
no_log: True
|
||
|
|
||
|
- name: Generate SSH key pair if missing
|
||
|
openssh_keypair:
|
||
|
path: "{{ __droneci_autoscaler_workdir }}/ssh_key"
|
||
|
type: ed25519
|
||
|
force: False
|
||
|
state: present
|
||
|
|
||
|
- 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
|