--- - name: Pin Django from Debian experimental until bullseye-backports exists template: src: "apt/{{ item }}.j2" dest: "/etc/apt/{{ item }}" loop: - sources.list.d/experimental.list - preferences.d/django-experimental - name: Install constellation dependencies apt: update_cache: true install_recommends: false name: - gettext - python3-django - python3-django-extensions - python3-django-polymorphic - python3-ipython - python3-pip - python3-psycopg2 register: apt_result retries: 3 until: apt_result is succeeded - name: Install constellation pip dependencies pip: name: - git+https://gitlab.adm.crans.org/nounous/django-dnsmanager.git - name: Set configuration directories in development mode when: constellation.version != "master" set_fact: config_file: "/var/local/constellation/constellation/settings_local.py" config_dir: "/var/local/constellation" project_path: "/var/local/constellation" - name: Set configuration directories in production mode when: constellation.version == "master" set_fact: config_file: "/etc/constellation/settings_local.py" config_dir: "/etc/constellation" project_path: "/usr/local/lib/python3.9/dist-packages/constellation" - name: Create constellation directory file: path: "{{ config_dir }}" state: directory mode: '2775' owner: "{{ constellation.owner }}" group: "{{ constellation.group }}" - name: Set ACL for constellation directory acl: path: "{{ config_dir }}" default: true entity: nounou etype: group permissions: rwx state: query ignore_errors: "{{ ansible_check_mode }}" - name: Clone constellation repository (development) when: constellation.version != "master" git: repo: 'https://gitlab.adm.crans.org/nounous/constellation.git' dest: "{{ project_path }}" umask: '002' version: "{{ constellation.version }}" recursive: true - name: Install constellation (production) when: constellation.version == "master" pip: name: - git+https://gitlab.adm.crans.org/nounous/constellation.git - name: Set owner of cloned project when: constellation.version != "master" file: path: "{{ project_path }}" owner: "{{ constellation.owner }}" group: "{{ constellation.group }}" recurse: true - name: Deploy Constellation settings_local.py template: src: constellation/settings_local.py.j2 dest: "{{ config_file }}" mode: 0660 owner: "{{ constellation.settings_local_owner }}" group: "{{ constellation.settings_local_group }}" - name: Symlink configuration file (production) when: constellation.version == "master" file: src: "{{ config_file }}" dest: "{{ project_path }}/settings_local.py" state: link - name: Compile messages when: not constellation.front django_manage: command: compilemessages project_path: "{{ project_path }}" # In the future, migrations will be included in the repository. - name: Make Django migrations (non-front app) when: not constellation.front django_manage: command: makemigrations project_path: "{{ project_path }}" - name: Migrate database (non-front app) when: not constellation.front django_manage: command: migrate project_path: "{{ project_path }}" - name: Load initial data (non-front app) when: not constellation.front django_manage: command: loaddata initial project_path: "{{ project_path }}" - name: Indicate constellation in motd template: src: update-motd.d/05-service.j2 dest: /etc/update-motd.d/05-constellation mode: 0755