Merge branch '2-refactor-vars' into 'master'
✅Resolve "refactor vars" Closes #2 and #9 See merge request lydra/yunohost/ansible-yunohost!3
This commit is contained in:
commit
f6c6f1d144
7 changed files with 188 additions and 91 deletions
75
README-FR.md
Normal file
75
README-FR.md
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
# ansible-yunohost
|
||||||
|
[🇬🇧 English version](README.md)
|
||||||
|
|
||||||
|
Deployez Yunohost avec Ansible !
|
||||||
|
|
||||||
|
## Prérequis
|
||||||
|
|
||||||
|
Aucun.
|
||||||
|
|
||||||
|
## Role Variables
|
||||||
|
Les variables par défaut sont disponibles dans `default/main.yml` cependant il est nécessaire de les surcharger selon vos besoins en termes de domaines, d'utilisateurs et d'applications sur Yunohost.
|
||||||
|
|
||||||
|
## Exemple de Variables
|
||||||
|
```yml
|
||||||
|
---
|
||||||
|
# Debian 10 script only.
|
||||||
|
ynh_install_script_url: https://install.yunohost.org
|
||||||
|
|
||||||
|
ynh_admin_password: MYINSECUREPWD_PLZ_OVERRIDE_THIS
|
||||||
|
|
||||||
|
# The list of domains.
|
||||||
|
ynh_main_domain: domain.tld
|
||||||
|
ynh_extra_domains:
|
||||||
|
- forum.domain.tld
|
||||||
|
- wiki.domain.tld
|
||||||
|
ynh_ignore_dyndns_server: False
|
||||||
|
|
||||||
|
# The list of Yunohost users.
|
||||||
|
ynh_users:
|
||||||
|
- name: user1
|
||||||
|
pass: MYINSECUREPWD_PLZ_OVERRIDE_THIS
|
||||||
|
firstname: Jane
|
||||||
|
lastname: Doe
|
||||||
|
mail_domain: domain.tld
|
||||||
|
|
||||||
|
# The list of Yunohost apps.
|
||||||
|
ynh_apps:
|
||||||
|
- label: WikiJS # Label is important, it's a reference for the Playbook.
|
||||||
|
link: wikijs # It can be the name of an official app or a git repo link.
|
||||||
|
args: # Provide args. Domain and pah are mandatory, for other args read manifest.json of app.
|
||||||
|
domain: wiki.domain.tld
|
||||||
|
path: /
|
||||||
|
admin: user1
|
||||||
|
is_public: no
|
||||||
|
- label: Discourse
|
||||||
|
link: discourse
|
||||||
|
args:
|
||||||
|
domain: forum.domain.tld
|
||||||
|
path: /
|
||||||
|
admin: user1
|
||||||
|
is_public: yes
|
||||||
|
```
|
||||||
|
## Dépendances
|
||||||
|
|
||||||
|
Aucune.
|
||||||
|
|
||||||
|
## Exemple de Playbook
|
||||||
|
```yml
|
||||||
|
---
|
||||||
|
- name: Install Yunohost on Debian Server
|
||||||
|
hosts: all
|
||||||
|
become: True
|
||||||
|
pre_tasks:
|
||||||
|
- name: Update all packages and index
|
||||||
|
ansible.builtin.apt:
|
||||||
|
upgrade: dist
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- ansible-yunohost
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
GPL-3.0
|
99
README.md
99
README.md
|
@ -1,73 +1,76 @@
|
||||||
ansible-yunohost
|
# ansible-yunohost
|
||||||
=========
|
[🇫🇷 French version](README-FR.md)
|
||||||
|
|
||||||
Deploy Yunohost with Ansible!
|
Deploy Yunohost with Ansible!
|
||||||
|
|
||||||
Requirements
|
## Requirements
|
||||||
------------
|
|
||||||
|
|
||||||
None.
|
None.
|
||||||
|
|
||||||
Role Variables
|
## Role Variables
|
||||||
--------------
|
Default variables are available in `default/main.yml` however it is necessary to override them according to your needs for Yunohost domains, users and apps.
|
||||||
|
|
||||||
Example of Variables:
|
## Example of Variables
|
||||||
```yml
|
```yml
|
||||||
yunohost:
|
---
|
||||||
# Link to the install script
|
# Debian 10 script only.
|
||||||
install_script_url: https://raw.githubusercontent.com/YunoHost/install_script/master/install_yunohost
|
ynh_install_script_url: https://install.yunohost.org
|
||||||
# The main domain, then a list of other domains.
|
|
||||||
domain: example.com
|
ynh_admin_password: MYINSECUREPWD_PLZ_OVERRIDE_THIS
|
||||||
extra_domains:
|
|
||||||
- example2.com
|
# The list of domains.
|
||||||
- example3.com
|
ynh_main_domain: domain.tld
|
||||||
# Yunohost admin password
|
ynh_extra_domains:
|
||||||
password: MYINSECUREPWD_PLZ_OVERRIDE_THIS
|
- forum.domain.tld
|
||||||
# If you don't want to use a noho.st url
|
- wiki.domain.tld
|
||||||
ignore_dyndns: False
|
ynh_ignore_dyndns_server: False
|
||||||
# The list of apps you want to install.
|
|
||||||
apps:
|
# The list of Yunohost users.
|
||||||
- label: Tiny Tiny RSS # Label is important, it's a reference for the Playbook.
|
ynh_users:
|
||||||
link: ttrss # It can be the name of an official app or a github link
|
- name: user1
|
||||||
args: # Provide here args. Path and domain are mandatory, other args depend of the app (cf manifest.json of app).
|
pass: MYINSECUREPWD_PLZ_OVERRIDE_THIS
|
||||||
path: /ttrss
|
firstname: Jane
|
||||||
domain: example.com
|
lastname: Doe
|
||||||
# The list of frontend users.
|
mail_domain: domain.tld
|
||||||
users:
|
|
||||||
- name: user1 # user which uses the default domain for its account
|
# The list of Yunohost apps.
|
||||||
pass: p@ssw0rd
|
ynh_apps:
|
||||||
firstname: Jane
|
- label: WikiJS # Label is important, it's a reference for the Playbook.
|
||||||
lastname: Doe
|
link: wikijs # It can be the name of an official app or a git repo link.
|
||||||
domain: '{{ domain }}'
|
args: # Provide args. Domain and pah are mandatory, for other args read manifest.json of app.
|
||||||
- name: user2 # user which uses the first extra_domain for its account
|
domain: wiki.domain.tld
|
||||||
pass: p@ssw0rd
|
path: /
|
||||||
firstname: John
|
admin: user1
|
||||||
lastname: Doe
|
is_public: no
|
||||||
domain: '{{ extra_domain.[1] }}'
|
- label: Discourse
|
||||||
|
link: discourse
|
||||||
|
args:
|
||||||
|
domain: forum.domain.tld
|
||||||
|
path: /
|
||||||
|
admin: user1
|
||||||
|
is_public: yes
|
||||||
```
|
```
|
||||||
|
|
||||||
Dependencies
|
## Dependencies
|
||||||
------------
|
|
||||||
|
|
||||||
None.
|
None.
|
||||||
|
|
||||||
Example Playbook
|
## Example Playbook
|
||||||
----------------
|
|
||||||
```yml
|
```yml
|
||||||
- name: Provision servers
|
---
|
||||||
|
- name: Install Yunohost on Debian Server
|
||||||
hosts: all
|
hosts: all
|
||||||
remote_user: root
|
become: True
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
- name: Update all packages and index
|
- name: Update all packages and index
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
upgrade: dist
|
upgrade: dist
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- { role: sylvainar.yunohost }
|
- ansible-yunohost
|
||||||
```
|
```
|
||||||
|
|
||||||
License
|
## License
|
||||||
-------
|
|
||||||
|
|
||||||
GPL-3.0
|
GPL-3.0
|
||||||
|
|
|
@ -1,9 +1,26 @@
|
||||||
yunohost:
|
---
|
||||||
install_script_url: https://install.yunohost.org/
|
# Debian 10 script only.
|
||||||
domain: example.com
|
ynh_install_script_url: https://install.yunohost.org
|
||||||
extra_domains: ~
|
|
||||||
password: MYINSECUREPWD_PLZ_OVERRIDE_THIS
|
|
||||||
ignore_dyndns: False
|
|
||||||
apps: ~
|
|
||||||
users: ~
|
|
||||||
|
|
||||||
|
ynh_admin_password: MYINSECUREPWD_PLZ_OVERRIDE_THIS
|
||||||
|
|
||||||
|
# The list of Yunohost domains.
|
||||||
|
ynh_main_domain: domain.tld
|
||||||
|
ynh_extra_domains: null
|
||||||
|
ynh_ignore_dyndns_server: False
|
||||||
|
|
||||||
|
# The list of Yunohost users.
|
||||||
|
ynh_users: null
|
||||||
|
# - name: user1
|
||||||
|
# pass: p@ssw0rd
|
||||||
|
# firstname: Jane
|
||||||
|
# lastname: Doe
|
||||||
|
# mail_domain: domain.tld
|
||||||
|
|
||||||
|
# The list of Yunohost apps.
|
||||||
|
ynh_apps: null
|
||||||
|
# - label: Tiny Tiny RSS # Label is important, it's a reference for the Playbook.
|
||||||
|
# link: ttrss # It can be the name of an official ynh app or a git repo link
|
||||||
|
# args: # Provide args here. Domain and path are mandatory, other args depend on the app (cf manifest.json of app).
|
||||||
|
# domain: domain.tld
|
||||||
|
# path: /ttrss
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
---
|
---
|
||||||
- name: List currently installed apps
|
- name: List currently installed apps
|
||||||
ansible.builtin.shell: yunohost app map --output-as json
|
ansible.builtin.shell: yunohost app map --output-as json
|
||||||
register: yunohost_installed_apps_raw
|
register: ynh_installed_apps_raw
|
||||||
changed_when: False
|
changed_when: False
|
||||||
|
|
||||||
- name: Format json of apps
|
- name: Format json of apps
|
||||||
ansible.builtin.set_fact: yunohost_installed_apps="{{ yunohost_installed_apps_raw.stdout | from_json }}"
|
ansible.builtin.set_fact: ynh_installed_apps="{{ ynh_installed_apps_raw.stdout | from_json }}"
|
||||||
|
|
||||||
- name: Install apps
|
- name: Install yunohost apps
|
||||||
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 %}"
|
ansible.builtin.shell: yunohost app install {{ item.link }} \
|
||||||
with_items: "{{ yunohost.apps }}"
|
--label "{{ item.label }}" \
|
||||||
when: item.label not in yunohost_installed_apps.values()
|
--args "{% for key, value in item.args.items() %}{{ key }}={{ value
|
||||||
|
}}{% if not loop.last %}&{% endif %}{% endfor %}"
|
||||||
|
with_items: "{{ ynh_apps }}"
|
||||||
|
when: item.label not in ynh_installed_apps.values()
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
---
|
---
|
||||||
- name: List currently installed domains
|
- name: List currently installed domains
|
||||||
ansible.builtin.shell: yunohost domain list --output-as json
|
ansible.builtin.shell: yunohost domain list --output-as json
|
||||||
register: yunohost_installed_domains_raw
|
register: ynh_installed_domains_raw
|
||||||
changed_when: False
|
changed_when: False
|
||||||
|
|
||||||
- name: Format json of domains
|
- name: Format json of domains
|
||||||
ansible.builtin.set_fact: yunohost_installed_domains="{{ yunohost_installed_domains_raw.stdout | from_json }}"
|
ansible.builtin.set_fact: ynh_installed_domains="{{ ynh_installed_domains_raw.stdout | from_json }}"
|
||||||
|
|
||||||
- name: Create domains
|
- name: Create domains
|
||||||
ansible.builtin.shell: yunohost domain add {{ item }}
|
ansible.builtin.shell: yunohost domain add {{ item }}
|
||||||
with_items: "{{ yunohost.extra_domains }}"
|
with_items: "{{ ynh_extra_domains }}"
|
||||||
when: item not in yunohost_installed_domains.domains
|
when: item not in ynh_installed_domains.domains
|
||||||
|
|
|
@ -8,43 +8,42 @@
|
||||||
|
|
||||||
- name: Test if Yunohost is already installed
|
- name: Test if Yunohost is already installed
|
||||||
ansible.builtin.stat: path=/etc/yunohost/installed
|
ansible.builtin.stat: path=/etc/yunohost/installed
|
||||||
register: yunohost_file_install
|
register: ynh_file_install
|
||||||
|
|
||||||
- name: Download install script
|
- name: Download Yunohost install script
|
||||||
ansible.builtin.get_url:
|
ansible.builtin.get_url:
|
||||||
url: "{{ yunohost.install_script_url }}"
|
url: "{{ ynh_install_script_url }}"
|
||||||
dest: /tmp/install_yunohost.sh
|
dest: /tmp/install_yunohost.sh
|
||||||
mode: 700
|
mode: 700
|
||||||
when: yunohost_file_install.stat.exists == False
|
when: ynh_file_install.stat.exists == False
|
||||||
|
|
||||||
- name: Launch script
|
- name: Launch Yunohost install script
|
||||||
ansible.builtin.command: /tmp/install_yunohost.sh -a
|
ansible.builtin.command: /tmp/install_yunohost.sh -a
|
||||||
when: yunohost_file_install.stat.exists == False
|
when: ynh_file_install.stat.exists == False
|
||||||
|
|
||||||
- name: Launch postinsstall
|
- name: Launch Yunohost postinstall
|
||||||
ansible.builtin.shell: "
|
ansible.builtin.shell: "
|
||||||
yunohost tools postinstall \
|
yunohost tools postinstall \
|
||||||
--domain {{ yunohost.domain }} \
|
--domain {{ ynh_main_domain }} \
|
||||||
--password {{ yunohost.password }} \
|
--password {{ ynh_admin_password }} \
|
||||||
{% if yunohost.ignore_dyndns == True %} --ignore-dyndns {% endif %}
|
{% if ynh_ignore_dyndns_server == True %} --ignore-dyndns {% endif %}"
|
||||||
"
|
when: ynh_file_install.stat.exists == False
|
||||||
when: yunohost_file_install.stat.exists == False
|
|
||||||
|
|
||||||
- name: Create domains
|
- name: Create extra domains
|
||||||
ansible.builtin.include: domains.yml
|
ansible.builtin.include: domains.yml
|
||||||
when: yunohost.extra_domains
|
when: ynh_extra_domains
|
||||||
|
|
||||||
- name: Run diagnosis # Required to install certificates
|
- name: Run first Yunohost diagnosis
|
||||||
ansible.builtin.shell: yunohost diagnosis run
|
ansible.builtin.shell: yunohost diagnosis run
|
||||||
|
|
||||||
- name: Install certificates
|
- name: Install domain certificates
|
||||||
ansible.builtin.shell: yunohost domain cert-install
|
ansible.builtin.shell: yunohost domain cert-install
|
||||||
changed_when: False
|
changed_when: False
|
||||||
|
|
||||||
- name: Add users
|
- name: Add Yunohost users
|
||||||
ansible.builtin.include: users.yml
|
ansible.builtin.include: users.yml
|
||||||
when: yunohost.users
|
when: ynh_users
|
||||||
|
|
||||||
- name: Install apps
|
- name: Install Yunohost apps
|
||||||
ansible.builtin.include: apps.yml
|
ansible.builtin.include: apps.yml
|
||||||
when: yunohost.apps
|
when: ynh_apps
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
---
|
---
|
||||||
- name: List users
|
- name: List users
|
||||||
ansible.builtin.shell: yunohost user list --output-as json
|
ansible.builtin.shell: yunohost user list --output-as json
|
||||||
register: yunohost_registered_users_raw
|
register: ynh_registered_users_raw
|
||||||
changed_when: False
|
changed_when: False
|
||||||
|
|
||||||
- name: Format json of users
|
- name: Format json of users
|
||||||
ansible.builtin.set_fact: yunohost_registered_users="{{ yunohost_registered_users_raw.stdout | from_json }}"
|
ansible.builtin.set_fact: ynh_registered_users="{{ ynh_registered_users_raw.stdout | from_json }}"
|
||||||
|
|
||||||
- name: Create missing users
|
- name: Create missing Yunohost users
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
yunohost user create {{ item.name }} \
|
yunohost user create {{ item.name }} \
|
||||||
-f {{ item.firstname }} \
|
-f {{ item.firstname }} \
|
||||||
-l {{ item.lastname }} \
|
-l {{ item.lastname }} \
|
||||||
-d {{ item.mail_domain }} \
|
-d {{ item.mail_domain }} \
|
||||||
-p {{ item.pass }}
|
-p {{ item.pass }}
|
||||||
loop: "{{ yunohost.users }}"
|
loop: "{{ ynh_users }}"
|
||||||
when: item.name not in yunohost_registered_users.users.keys()
|
when: item.name not in ynh_registered_users.users.keys()
|
||||||
|
|
Loading…
Reference in a new issue