Skip to content
Snippets Groups Projects
main.yml 5.94 KiB
---

- name: mediaserver install
  apt:
    force_apt_get: true
    install_recommends: false
    name: "{{ server_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: fetch ssh public key
  register: root_ssh_pubkey
  slurp:
    path: /root/.ssh/id_ed25519.pub
  tags: always

- name: register ssh public key as an ansible fact
  set_fact:
    pubkey: "{{ root_ssh_pubkey['content'] | b64decode }}"
  tags: always

- name: share ssh public key between cluster members
  loop: "{{ groups['mediaserver'] }}"
  authorized_key:
    user: root
    key: "{{ hostvars[item]['pubkey'] }}"
  tags: always

- name: resolve domain name to localhost
  when: not in_docker
  notify: restart nginx
  loop: "{{ server_instances }}"
  lineinfile:
    path: /etc/hosts
    line: '127.0.1.1 {{ item.ms_server_name }}'
    backup: true

# - name: synchronize configuration
#   when: groups['mediaserver'] | length > 1
#   loop:
#     - /etc/passwd
#     - /etc/shadow
#     - /etc/group
#   synchronize:
#     src: "{{ item }}"
#     dest: "{{ item }}"
#     mode: push
#     copy_links: yes
#     set_remote_user: no
#   delegate_to: "{{ groups['mediaserver'][0] }}"
#   tags: always

- name: create celerity-config
  notify: restart celerity-server
  template:
    src: celerity-config.py.j2
    dest: /etc/celerity/config.py
  when:
    - inventory_hostname not in groups['celerity']
  changed_when: "'molecule-idempotence-notest' not in ansible_skip_tags"

- name: create instances
  when: inventory_hostname == groups['mediaserver'][0]
  loop: "{{ server_instances }}"
  environment:
    MS_ID: "{{ item.ms_id }}"
    MS_SERVER_NAME: "{{ item.ms_server_name }}"
    MS_API_KEY: "{{ item.ms_api_key }}"
    CM_SERVER_NAME: "{{ item.cm_server_name }}"