This repository has been archived on 2025-05-03. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
transip-client-ansible/roles/transip_client/tasks/main.yml

79 lines
1.9 KiB
YAML

- name: load OS specific vars
include_vars: "{{ item }}"
with_first_found:
- files:
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }}.yml"
- "{{ ansible_distribution|lower }}.yml"
- "{{ ansible_os_family|lower }}.yml"
paths:
- "{{ role_path }}/vars"
- name: install packages
become: true
package:
name: "{{ item }}"
state: present
loop: "{{ packages }}"
- name: clone project
git:
repo: "{{ app_url }}"
dest: "{{ app_dir }}"
version: "{{ app_branch }}"
update: yes
- name: include poetry tasks
include_role:
name: common
tasks_from: "poetry.yml"
vars:
poetry_user: "{{ ansible_user_id }}"
poetry_dir: "{{ ansible_env.HOME }}/.poetry"
- name: run poetry tasks
block:
- name: retrieve user $PATH
shell: "echo $PATH"
register: path_stats
- name: set poetry user variables
set_fact:
poetry_user_path: "{{ path_stats.stdout }}"
- name: set default venv python version
command: "poetry env use python3.7"
args:
chdir: "{{ app_dir }}"
environment:
PATH: "/home/{{ app_user }}/.local/bin:{{ poetry_user_path }}"
- name: install project dependencies
command:
argv:
- "poetry install"
- "--no-dev"
args:
chdir: "{{ app_dir }}"
environment:
PATH: "/home/{{ app_user }}/.local/bin:{{ poetry_user_path }}"
- name: copy environment file
template:
src: "env.j2"
dest: "{{ app_dir }}/.env"
mode: 0600
- name: copy systemd templates
template:
loop:
- {
src: "timer.j2",
dest: "{{ systemd_dir }}/transip-client.timer",
mode: "0644",
}
- {
src: "service.j2",
dest: "{{ systemd_dir }}/transip-client.service",
mode: "0644",
}
notify: enable transip-client timer