From 9ce7c315a03441841961beab4abf56839eb0c78a Mon Sep 17 00:00:00 2001 From: therojam Date: Sat, 1 May 2021 17:13:18 +0200 Subject: [PATCH 1/2] upgraded code for ansible version 2.10/3 --- README.md | 4 ++-- tasks/apps.yml | 6 +++--- tasks/domains.yml | 6 +++--- tasks/main.yml | 20 ++++++++++---------- tasks/users.yml | 8 ++++---- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 4c5be0d..9942297 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ansible-yunohost ========= -Deploy Yunohost with Ansible ! +Deploy Yunohost with Ansible! Requirements ------------ @@ -54,7 +54,7 @@ Example Playbook remote_user: root pre_tasks: - name: Update all packages and index - apt: + ansible.builtin.apt: upgrade: dist update_cache: yes diff --git a/tasks/apps.yml b/tasks/apps.yml index 45a1f8b..37776b1 100644 --- a/tasks/apps.yml +++ b/tasks/apps.yml @@ -1,13 +1,13 @@ --- - name: List currently installed apps - shell: yunohost app map --output-as json + ansible.builtin.shell: yunohost app map --output-as json register: yunohost_installed_apps_raw changed_when: False - name: Format json of apps - set_fact: yunohost_installed_apps="{{ yunohost_installed_apps_raw.stdout | from_json }}" + ansible.builtin.set_fact: yunohost_installed_apps="{{ yunohost_installed_apps_raw.stdout | from_json }}" - name: Install apps - shell: yunohost app install {{ item.link }} --label "{{ item.label }}" --args "{% for key, value in item.args.items() %}{{key}}={{value}}{% if not loop.last %}&{% endif %}{% endfor %}" + ansible.builtin.shell: yunohost app install {{ item.link }} --label "{{ item.label }}" --args "{% for key, value in item.args.items() %}{{key}}={{value}}{% if not loop.last %}&{% endif %}{% endfor %}" with_items: "{{ yunohost.apps }}" when: item.label not in yunohost_installed_apps.values() diff --git a/tasks/domains.yml b/tasks/domains.yml index f2d26bb..c6c1424 100644 --- a/tasks/domains.yml +++ b/tasks/domains.yml @@ -1,13 +1,13 @@ --- - name: List currently installed domains - shell: yunohost domain list --output-as json + ansible.builtin.shell: yunohost domain list --output-as json register: yunohost_installed_domains_raw changed_when: False - name: Format json of domains - set_fact: yunohost_installed_domains="{{ yunohost_installed_domains_raw.stdout | from_json }}" + ansible.builtin.set_fact: yunohost_installed_domains="{{ yunohost_installed_domains_raw.stdout | from_json }}" - name: Create domains - shell: yunohost domain add {{ item }} + ansible.builtin.shell: yunohost domain add {{ item }} with_items: "{{ yunohost.extra_domains }}" when: item not in yunohost_installed_domains.domains diff --git a/tasks/main.yml b/tasks/main.yml index e5af5d0..b01d51b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,28 +1,28 @@ --- - name: Install requirements - apt: + ansible.builtin.apt: name: - git - dialog state: present - name: Test if Yunohost is already installed - stat: path=/etc/yunohost/installed + ansible.builtin.stat: path=/etc/yunohost/installed register: yunohost_file_install - name: Download install script - get_url: + ansible.builtin.get_url: url: "{{ yunohost.install_script_url }}" dest: /tmp/install_yunohost.sh mode: 700 when: yunohost_file_install.stat.exists == False - name: Launch script - command: /tmp/install_yunohost.sh -a + ansible.builtin.command: /tmp/install_yunohost.sh -a when: yunohost_file_install.stat.exists == False - name: Launch postinsstall - shell: " + ansible.builtin.shell: " yunohost tools postinstall \ --domain {{ yunohost.domain }} \ --password {{ yunohost.password }} \ @@ -31,20 +31,20 @@ when: yunohost_file_install.stat.exists == False - name: Create domains - include: domains.yml + ansible.builtin.include: domains.yml when: yunohost.extra_domains - name: Run diagnosis # Required to install certificates - shell: yunohost diagnosis run + ansible.builtin.shell: yunohost diagnosis run - name: Install certificates - shell: yunohost domain cert-install + ansible.builtin.shell: yunohost domain cert-install changed_when: False - name: Add users - include: users.yml + ansible.builtin.include: users.yml when: yunohost.users - name: Install apps - include: apps.yml + ansible.builtin.include: apps.yml when: yunohost.apps diff --git a/tasks/users.yml b/tasks/users.yml index 6310a6d..910006c 100644 --- a/tasks/users.yml +++ b/tasks/users.yml @@ -1,18 +1,18 @@ --- - name: List users - shell: yunohost user list --output-as json + ansible.builtin.shell: yunohost user list --output-as json register: yunohost_registered_users_raw changed_when: False - name: Format json of users - set_fact: yunohost_registered_users="{{ yunohost_registered_users_raw.stdout | from_json }}" + ansible.builtin.set_fact: yunohost_registered_users="{{ yunohost_registered_users_raw.stdout | from_json }}" - name: Create missing users - shell: | + ansible.builtin.shell: | yunohost user create {{ item.name }} \ -f {{ item.firstname }} \ -l {{ item.lastname }} \ -m {{ item.mail }} \ -p {{ item.pass }} - with_items: "{{ yunohost.users }}" + loop: "{{ yunohost.users }}" when: item.name not in yunohost_registered_users.users.keys() From c6adcf5850f763e5eaa3ce15cc3a3ef1105e2e63 Mon Sep 17 00:00:00 2001 From: therojam Date: Sat, 1 May 2021 17:24:41 +0200 Subject: [PATCH 2/2] updated meta data --- meta/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/meta/main.yml b/meta/main.yml index 3d2bc99..7080595 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,13 +1,15 @@ galaxy_info: + role_name: yunohost author: sylvainar description: Deploy Yunohost with Ansible license: GPL-v3 - min_ansible_version: 1.2 + min_ansible_version: 2.10 galaxy_tags: [yunohost] platforms: - name: Debian versions: - jessie + - buster categories: - cloud - web