Skip to content
Snippets Groups Projects
main.yml 3.53 KiB
---
- name: proxy
  when:
    - proxy_http | d()
    - proxy_https | d()
  ansible.builtin.include_role:
    name: proxy

- name: install requirements
  ansible.builtin.apt:
    force_apt_get: true
    install_recommends: false
    name: "{{ conf_req_packages }}"
  register: apt_status
  retries: 60
  until: apt_status is success or ('Failed to lock apt for exclusive operation' not in apt_status.msg and '/var/lib/dpkg/lock' not in apt_status.msg)

- name: install online requirements
  when: not offline_mode | d(false)
  ansible.builtin.apt:
    force_apt_get: true
    install_recommends: false
    name: "{{ conf_req_packages_online }}"
  register: apt_status
  retries: 60
  until: apt_status is success or ('Failed to lock apt for exclusive operation' not in apt_status.msg and '/var/lib/dpkg/lock' not in apt_status.msg)

- name: generate root ssh key pair
  register: conf_root
  ansible.builtin.user:
    name: root
    generate_ssh_key: true
    ssh_key_type: ed25519
    ssh_key_file: .ssh/id_ed25519

- name: create conf dir
  ansible.builtin.file:
    path: "{{ conf_dir }}"
    state: directory
    mode: "0700"

- name: check if auto-generated-conf.sh exists
  check_mode: false
  register: check_auto_conf
  ansible.builtin.stat:
    path: "{{ conf_dir }}/auto-generated-conf.sh"

- name: download conf and update ssh public key with activation key
  when: skyreach_activation_key | d(false)
  register: conf_dl_ak
  changed_when: conf_dl_ak.status == 200
  failed_when:
    - conf_dl_ak.status != 200
    - not check_auto_conf.stat.exists
    - not skyreach_system_key
  ansible.builtin.uri:
    url: https://{{ conf_host }}/erp/credentials/envsetup-conf.sh
    method: POST
    body_format: form-urlencoded
    body:
      key: "{{ skyreach_activation_key }}"
      public_key: "{{ conf_root.ssh_public_key }}"
    return_content: true
    validate_certs: "{{ conf_valid_cert }}"

- name: download conf and update ssh public key with system key
  when:
    - not check_auto_conf.stat.exists or conf_update
    - skyreach_system_key | d(false)
  register: conf_dl_sk