From 8de557346e99ec34938932906575a0c6e5447f2f Mon Sep 17 00:00:00 2001 From: Emilien Mantel Date: Fri, 10 Sep 2021 15:52:29 +0200 Subject: [PATCH] Some code refactoring on install process --- .../Debian.yml} | 26 ------------------ .../FreeBSD.yml} | 0 tasks/install/acme.yml | 27 +++++++++++++++++++ tasks/install/main.yml | 7 +++++ tasks/main.yml | 2 +- 5 files changed, 35 insertions(+), 27 deletions(-) rename tasks/{install_Debian.yml => install/Debian.yml} (56%) rename tasks/{install_FreeBSD.yml => install/FreeBSD.yml} (100%) create mode 100644 tasks/install/acme.yml create mode 100644 tasks/install/main.yml diff --git a/tasks/install_Debian.yml b/tasks/install/Debian.yml similarity index 56% rename from tasks/install_Debian.yml rename to tasks/install/Debian.yml index 9f0d3ab..f4eb94c 100644 --- a/tasks/install_Debian.yml +++ b/tasks/install/Debian.yml @@ -25,29 +25,3 @@ ansible.builtin.apt: pkg: "python{% if ansible_python_version is version('3', '>=') %}3{% endif %}-passlib" state: present - -- name: STAT | Check acme.sh is installed - ansible.builtin.stat: - path: "{{ nginx_acmesh_dir }}" - register: acme - -- block: - - - name: APT | Install git - ansible.builtin.apt: - pkg: git - - - name: GIT | Get acme.sh - ansible.builtin.git: - repo: 'https://github.com/Neilpang/acme.sh.git' - dest: '{{ nginx_acmesh_git_dir }}' - update: false - version: master - - - name: COMMAND | Install acme.sh - ansible.builtin.command: ./acme.sh --install --home "{{ nginx_acmesh_dir }}" - args: - chdir: "{{ nginx_acmesh_git_dir }}" - creates: "{{ nginx_acmesh_dir }}" - - when: not acme.stat.exists diff --git a/tasks/install_FreeBSD.yml b/tasks/install/FreeBSD.yml similarity index 100% rename from tasks/install_FreeBSD.yml rename to tasks/install/FreeBSD.yml diff --git a/tasks/install/acme.yml b/tasks/install/acme.yml new file mode 100644 index 0000000..b30d8a5 --- /dev/null +++ b/tasks/install/acme.yml @@ -0,0 +1,27 @@ +--- + +- name: STAT | Check acme.sh is installed + ansible.builtin.stat: + path: "{{ nginx_acmesh_dir }}" + register: acme + +- block: + + - name: APT | Install git + ansible.builtin.apt: + pkg: git + + - name: GIT | Get acme.sh + ansible.builtin.git: + repo: 'https://github.com/Neilpang/acme.sh.git' + dest: '{{ nginx_acmesh_git_dir }}' + update: false + version: master + + - name: COMMAND | Install acme.sh + ansible.builtin.command: ./acme.sh --install --home "{{ nginx_acmesh_dir }}" + args: + chdir: "{{ nginx_acmesh_git_dir }}" + creates: "{{ nginx_acmesh_dir }}" + + when: not acme.stat.exists diff --git a/tasks/install/main.yml b/tasks/install/main.yml new file mode 100644 index 0000000..1d25321 --- /dev/null +++ b/tasks/install/main.yml @@ -0,0 +1,7 @@ +--- + +- name: INCLUDE_TASKS | Install + ansible.builtin.include_tasks: "{{ ansible_distribution }}.yml" + +- name: IMPORT_TASKS | acme + ansible.builtin.include_tasks: "acme.yml" diff --git a/tasks/main.yml b/tasks/main.yml index 6080100..7042c66 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,7 +5,7 @@ tags: ['nginx::site', 'nginx::ssl'] - name: INCLUDE_TASKS | Install - ansible.builtin.include_tasks: "install_{{ ansible_distribution }}.yml" + ansible.builtin.import_tasks: "install/main.yml" tags: ['nginx::site', 'nginx::ssl'] - name: IMPORT_TASKS| Prepare