From 037be6bb493eed2f46a3c78e76c79f3f067bdf21 Mon Sep 17 00:00:00 2001 From: hygienic-books Date: Mon, 11 Jul 2022 02:11:12 +0200 Subject: [PATCH] feat(python): Add ability to instal and run Python from Git --- .../tasks/55-setup-git-repo.yml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 ansible/roles/10-include-50-miniconda/tasks/55-setup-git-repo.yml diff --git a/ansible/roles/10-include-50-miniconda/tasks/55-setup-git-repo.yml b/ansible/roles/10-include-50-miniconda/tasks/55-setup-git-repo.yml new file mode 100644 index 0000000..d145dda --- /dev/null +++ b/ansible/roles/10-include-50-miniconda/tasks/55-setup-git-repo.yml @@ -0,0 +1,45 @@ +- name: 'Clone Python package Git repo ''{{ git.repo_url }}''' + ansible.builtin.git: + repo: '{{ git.repo_url }}' + dest: '{{ git.path }}/{{ git.branch }}' + + + +- name: 'If Git repo has config: Add config' + when: 'git.config_file' + ansible.builtin.copy: + src: '{{ git.config_file }}' + dest: '/{{ git.config_file }}' + mode: '0644' + + + +- name: 'If Git repo wants systemd: Copy systemd unit file' + when: '(git.systemd.service) and (git.systemd.timer)' + register: 'rv_copy_systemd_unit_files' + loop_control: + loop_var: 'unit' + label: '{{ unit.destination }}' + loop: + - { source: '{{ git.systemd.service }}', destination: '/{{ git.systemd.service }}', mode: '0644' } + - { source: '{{ git.systemd.timer }}', destination: '/{{ git.systemd.timer }}', mode: '0644' } + ansible.builtin.copy: + src: '{{ unit.source }}' + dest: '{{ unit.destination }}' + mode: '{{ unit.mode }}' + + + +- name: 'If systemd copy changed: systemctl daemon-reload' + when: '(rv_copy_systemd_unit_files.changed)' + ansible.builtin.systemd: + daemon_reload: 'yes' + + + +- name: 'If systemd copy succeeded: systemctl enable --now timer unit' + when: '(rv_copy_systemd_unit_files is success)' + ansible.builtin.systemd: + enabled: 'yes' + state: 'started' + name: '{{ git.systemd.timer | basename }}'