xoxys.droneci_autoscaler/tasks/setup.yml
Robert Kaussow 3af6d55088
All checks were successful
continuous-integration/drone/push Build is passing
fix: solve linting issues
2021-02-06 15:13:34 +01:00

58 lines
1.8 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.sshkey | default(droneci_autoscaler_sshkey)) | default('') }}"
- 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: "{{ __droneci_autoscaler_sshkey }}"
dest: "{{ __droneci_autoscaler_workdir }}/ssh_key"
mode: 0600
when: __droneci_autoscaler_sshkey | length > 0
no_log: True
- name: Generate SSH key pair
openssh_keypair:
path: "{{ __droneci_autoscaler_workdir }}/ssh_key"
type: ed25519
force: False
state: present
when: not __droneci_autoscaler_sshkey | length > 0
- name: Write userdata
template:
src: services/userdata.yml.j2
dest: "{{ __droneci_autoscaler_workdir }}/userdata.yml"
mode: 0640
notify: __droneci_autoscaler_restart
- 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