--- - name: create base directory file: path: "/var/lib/greenbone/{{ greenbone_server_hostname }}" state: directory - name: copy docker compose file template: src: "docker-compose-{{ greenbone_server_version }}.yml.j2" dest: "/var/lib/greenbone/{{ greenbone_server_hostname }}/docker-compose.yml" ## TODO: replace this with proper ansible modules once the v2 modules get released - name: get list of running compose projects check_mode: no command: "docker compose ls --format json --filter 'name=^{{ greenbone_server_hostname }}$'" changed_when: False register: greenbone_server_compose_list - name: initial compose setup when: (greenbone_server_compose_list.stdout | from_json | length) == 0 block: - name: pull greenbone images command: docker compose -f "/var/lib/greenbone/{{ greenbone_server_hostname }}/docker-compose.yml" -p "{{ greenbone_server_hostname | replace('.', '_') }}" pull - name: start greenbone command: docker compose -f "/var/lib/greenbone/{{ greenbone_server_hostname }}/docker-compose.yml" -p "{{ greenbone_server_hostname | replace('.', '_') }}" up -d - name: set admin password command: docker compose -f "/var/lib/greenbone/{{ greenbone_server_hostname }}/docker-compose.yml" -p "{{ greenbone_server_hostname | replace('.', '_') }}" exec -u gvmd gvmd gvmd --user=admin --new-password="{{ greenbone_server_admin_password }}" register: greenbone_server_set_admin_password until: "greenbone_server_set_admin_password is not failed" retries: 15 delay: 5 - name: compute nginx vhost config vars: greenbone_server_vhost_base: name: greenbone mode: "0600" template: generic hostnames: - "{{ greenbone_server_hostname }}" locations: '/': proxy_pass: "http://127.0.0.1:9392" greenbone_server_vhost_override__yaml: | {% if greenbone_server_tls is defined %} tls: {{ greenbone_server_tls | to_nice_yaml(indent=2) | indent(2) }} {% endif %} set_fact: greenbone_server_vhost: "{{ greenbone_server_vhost_base | combine(greenbone_server_vhost_override__yaml | from_yaml, recursive=True) }}" - name: configure nginx vhost vars: nginx_vhost: "{{ greenbone_server_vhost }}" include_role: name: nginx/vhost