diff --git a/.drone.yml b/.drone.yml index db19a1c..ef758ba 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,25 +3,24 @@ type: kubernetes name: turn steps: -- name: Check syntax - image: plugins/ansible:3 - settings: - playbook: playbook.yml - inventory: inventory.yml - galaxy: requirements.yml - syntax_check: true - - name: Apply playbook - image: plugins/ansible:3 + image: bv11-cr01.bessems.eu/library/packer-extended + commands: + - | + mkdir ~/.ssh && \ + echo "$${private_key}" > ~/.ssh/id_rsa && \ + chmod 0600 ~/.ssh/id_rsa + - ansible-galaxy collection install -r requirements.yml + - | + ansible-playbook \ + --inventory inventory.yml \ + playbook.yml + environment: + private_key: + from_secret: ssh_privatekey volumes: - name: certificates path: /certificates - settings: - playbook: playbook.yml - inventory: inventory.yml - galaxy: requirements.yml - private_key: - from_secret: ssh_privatekey volumes: - name: certificates diff --git a/playbook.yml b/playbook.yml index c831573..3035d05 100644 --- a/playbook.yml +++ b/playbook.yml @@ -6,5 +6,6 @@ coturn: version: 4.6-alpine roles: + - common - dockerhost - turn diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml new file mode 100644 index 0000000..1753f29 --- /dev/null +++ b/roles/common/tasks/main.yml @@ -0,0 +1,20 @@ +- name: Upgrade all packages + ansible.builtin.apt: + name: "*" + state: latest + update_cache: yes + +- name: Check if a reboot is needed + ansible.builtin.stat: + path: /var/run/reboot-required + get_checksum: no + register: rebootrequired + +- name: Trigger reboot + ansible.builtin.reboot: + msg: "Reboot initiated by Ansible due to kernel updates" + reboot_timeout: 300 + pre_reboot_delay: 0 + post_reboot_delay: 30 + test_command: uptime + when: rebootrequired.stat.exists \ No newline at end of file diff --git a/roles/turn/tasks/main.yml b/roles/turn/tasks/main.yml index 532768c..abd35b0 100644 --- a/roles/turn/tasks/main.yml +++ b/roles/turn/tasks/main.yml @@ -1,4 +1,21 @@ -- name: Run coturn container +- name: Get current running containers + community.docker.docker_host_info: + containers: yes + register: docker_info + +- name: Stop/Remove all current containers + community.docker.docker_container: + name: "{{ item }}" + state: absent + loop: "{{ docker_info.containers | map(attribute='Id') | list }}" + +- name: Prune everything + community.docker.docker_prune: + containers: yes + images: yes + volumes: yes + +- name: Start coturn container community.docker.docker_container: name: coturn image: bv11-cr01.bessems.eu/proxy/coturn/coturn:{{ coturn.version }} @@ -11,4 +28,6 @@ --no-tls \ --realm=dendrite network_mode: host + state: started restart_policy: unless-stopped + recreate: yes