diff --git a/defaults/main.yaml b/defaults/main.yaml index d6b2941..dbbde71 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -1,9 +1,11 @@ -env_vars: [] -acme_domains: [] -acme_user: "acme" -add_to_docker_group: true -acme_git_repo: "https://github.com/acmesh-official/acme.sh.git" -acme_sh_home: "/home/{{ acme_user }}/acme.sh" +acme_sh_env_vars: [] +acme_sh_domains: [] +acme_sh_user: "acme" +acme_sh_user_groups: [] +acme_sh_user_home: "/home/{{ acme_sh_user }}" +acme_sh_git_repo: "https://github.com/acmesh-official/acme.sh.git" +acme_sh_git_folder: "{{ acme_sh_user_home }}/git_acme.sh" +acme_sh_home: "{{ acme_sh_user_home }}/acme.sh" acme_sh_cert_home: "{{ acme_sh_home }}/certs" acme_sh_config_home: "{{ acme_sh_home }}/config" acme_sh_email: "" @@ -13,5 +15,5 @@ acme_sh_post_hook: "" acme_sh_renew_hook: "" acme_sh_set_notify: "" acme_sh_set_notify_level: "2" -docker_group: "docker" -acme_user_home: "/home/{{ acme_user }}" +acme_sh_docker_group: "" + diff --git a/tasks/install_acmesh.yml b/tasks/install_acmesh.yml index 2209f55..9647cf1 100644 --- a/tasks/install_acmesh.yml +++ b/tasks/install_acmesh.yml @@ -1,15 +1,17 @@ --- - name: Git fetch acme.sh repository ansible.builtin.git: - repo: "https://github.com/acmesh-official/acme.sh.git" - dest: "{{ acme_user_home }}/acme.sh" - -- name: Check acme.sh installation existence - ansible.builtin.stat: - path: "{{ acme_sh_home }}" - register: acme_sh_folder_stats + repo: "{{ acme_sh_git_repo }}" + dest: "{{ acme_sh_git_folder }}" - name: Install acme.sh - ansible.builtin.debug: - msg: "installing..." - when: acme_sh_folder_stats.stat.isdir is defined and acme_sh_folder_stats.stat.isdir \ No newline at end of file + ansible.builtin.command: + chdir: "{{ acme_sh_git_folder }}" + cmd: | + /bin/sh acme.sh + --install + --home {{ acme_sh_home | quote }} + --cert-home {{ acme_sh_cert_home | quote }} + --config-home {{ acme_sh_config_home | quote }} + -m {{ acme_sh_email | quote }} + creates: "{{ acme_sh_home }}" diff --git a/tasks/main.yaml b/tasks/main.yaml index 37d80db..ceba9b7 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -10,18 +10,17 @@ - name: Create acme user become: true ansible.builtin.user: - name: "{{ acme_user }}" + name: "{{ acme_sh_user }}" -- name: Add acme user to Docker group +- name: Add acme user to groups become: true ansible.builtin.user: - name: "{{ acme_user }}" - groups: "{{ docker_group }}" + name: "{{ acme_sh_user }}" + groups: "{{ acme_sh_user_groups }}" append: true - home: "{{ acme_user_home }}" - when: add_to_docker_group == true + when: acme_sh_user_groups|length > 0 - name: Install acme.sh become: true - become_user: "{{ acme_user }}" + become_user: "{{ acme_sh_user }}" ansible.builtin.import_tasks: "install_acmesh.yml" \ No newline at end of file