forked from TheRojam/ansible-yunohost
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2-refactor-vars' into 'master'
✅Resolve "refactor vars" Closes TheRojam#2 and sylvainar#9 See merge request lydra/yunohost/ansible-yunohost!3
- Loading branch information
Showing
7 changed files
with
188 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,76 @@ | ||
ansible-yunohost | ||
========= | ||
# ansible-yunohost | ||
[🇫🇷 French version](README-FR.md) | ||
|
||
Deploy Yunohost with Ansible! | ||
|
||
Requirements | ||
------------ | ||
## Requirements | ||
|
||
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 | ||
yunohost: | ||
# Link to the install script | ||
install_script_url: https://raw.githubusercontent.com/YunoHost/install_script/master/install_yunohost | ||
# The main domain, then a list of other domains. | ||
domain: example.com | ||
extra_domains: | ||
- example2.com | ||
- example3.com | ||
# Yunohost admin password | ||
password: MYINSECUREPWD_PLZ_OVERRIDE_THIS | ||
# If you don't want to use a noho.st url | ||
ignore_dyndns: False | ||
# The list of apps you want to install. | ||
apps: | ||
- label: Tiny Tiny RSS # Label is important, it's a reference for the Playbook. | ||
link: ttrss # It can be the name of an official app or a github link | ||
args: # Provide here args. Path and domain are mandatory, other args depend of the app (cf manifest.json of app). | ||
path: /ttrss | ||
domain: example.com | ||
# The list of frontend users. | ||
users: | ||
- name: user1 # user which uses the default domain for its account | ||
pass: p@ssw0rd | ||
firstname: Jane | ||
lastname: Doe | ||
domain: '{{ domain }}' | ||
- name: user2 # user which uses the first extra_domain for its account | ||
pass: p@ssw0rd | ||
firstname: John | ||
lastname: Doe | ||
domain: '{{ extra_domain.[1] }}' | ||
--- | ||
# 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 | ||
``` | ||
Dependencies | ||
------------ | ||
## Dependencies | ||
None. | ||
Example Playbook | ||
---------------- | ||
## Example Playbook | ||
```yml | ||
- name: Provision servers | ||
--- | ||
- name: Install Yunohost on Debian Server | ||
hosts: all | ||
remote_user: root | ||
become: True | ||
pre_tasks: | ||
- name: Update all packages and index | ||
ansible.builtin.apt: | ||
upgrade: dist | ||
update_cache: yes | ||
|
||
roles: | ||
- { role: sylvainar.yunohost } | ||
- ansible-yunohost | ||
``` | ||
License | ||
------- | ||
## License | ||
GPL-3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
yunohost: | ||
install_script_url: https://install.yunohost.org/ | ||
domain: example.com | ||
extra_domains: ~ | ||
password: MYINSECUREPWD_PLZ_OVERRIDE_THIS | ||
ignore_dyndns: False | ||
apps: ~ | ||
users: ~ | ||
--- | ||
# Debian 10 script only. | ||
ynh_install_script_url: https://install.yunohost.org | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
--- | ||
- name: List currently installed apps | ||
ansible.builtin.shell: yunohost app map --output-as json | ||
register: yunohost_installed_apps_raw | ||
register: ynh_installed_apps_raw | ||
changed_when: False | ||
|
||
- 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 | ||
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() | ||
- 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 %}" | ||
with_items: "{{ ynh_apps }}" | ||
when: item.label not in ynh_installed_apps.values() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
--- | ||
- name: List currently installed domains | ||
ansible.builtin.shell: yunohost domain list --output-as json | ||
register: yunohost_installed_domains_raw | ||
register: ynh_installed_domains_raw | ||
changed_when: False | ||
|
||
- 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 | ||
ansible.builtin.shell: yunohost domain add {{ item }} | ||
with_items: "{{ yunohost.extra_domains }}" | ||
when: item not in yunohost_installed_domains.domains | ||
with_items: "{{ ynh_extra_domains }}" | ||
when: item not in ynh_installed_domains.domains |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
--- | ||
- name: List users | ||
ansible.builtin.shell: yunohost user list --output-as json | ||
register: yunohost_registered_users_raw | ||
register: ynh_registered_users_raw | ||
changed_when: False | ||
|
||
- 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: | | ||
yunohost user create {{ item.name }} \ | ||
-f {{ item.firstname }} \ | ||
-l {{ item.lastname }} \ | ||
-d {{ item.mail_domain }} \ | ||
-p {{ item.pass }} | ||
loop: "{{ yunohost.users }}" | ||
when: item.name not in yunohost_registered_users.users.keys() | ||
loop: "{{ ynh_users }}" | ||
when: item.name not in ynh_registered_users.users.keys() |