Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit af492072 authored by Arthur BOUDREAULT's avatar Arthur BOUDREAULT
Browse files

refactor: add suggestions to readme + 660 mode for config files for better compatibility

parent cb9cc957
No related branches found
No related tags found
1 merge request!16Resolve "feat: add app post_install"
Pipeline #3017 passed with warnings
......@@ -96,31 +96,38 @@ ynh_apps:
admin: user1
is_public: yes
post_install:
- src: "templates/file.sh.j2"
dest: "/tmp/script.sh"
- src: "templates/site_settings.yml.j2"
dest: "/var/www/discourse/config/site_settings.yml"
type: "config"
- src: "templates/configure_discourse.sh.j2"
dest: "/tmp/configure_discourse.sh"
type: "script"
owner: root
group: root
```
- `ynh_apps` est la liste des applications à installer.
- `label` permet de donner un nom personnalisé à l'application sur l'interface utilisateur.
- `link` correspond au nom de l'application Yunohost qu'on veut installer.
**Concernant les arguments :**
#### Concernant les arguments :
- `domain` est indispensable. Il faut choisir un des domaines de son instance Yunohost.
- `path` est indispensable. Il faut choisir une URL pour accéder à son application comme `domain.tld/my_app`. Utilisez juste `/` si l'application doit s'installer sur un sous-domaine.
- `is_public` est un argument qu'on retrouve souvent. Paramétré sur `yes`, l'application sera accessible à tout le monde, même sans authentification sur le portail SSO Yunohost. Paramétré sur `no`, l'application ne sera accessible qu'après authentification.
Pour les autres arguments, il faut se référer au `manifest.json` disponible dans le dépôt de l'application Yunohost qu'on installe. Vous pouvez en apprendre plus sur cette partie [ici](https://yunohost.org/fr/packaging_apps_manifest).
**Concernant la post-installation :**
Il est possible de compléter l'installation des applications par l'ajout de fichiers de configuration ou de scripts que vous aurez écrit de votre côté.
Pour activer cette fonctionnalité, définissez la variable `post_install` qui correspond aux fichiers de post-installation de votre application.
#### Concernant la post-installation :
Il est possible de compléter l'installation des applications par l'ajout de templates jinja de configuration ou de scripts que vous aurez écrit de votre côté.
Pour activer cette fonctionnalité, définissez la variable `post_install` qui correspond à la liste des fichiers de post-installation de votre application.
Cette tâche utilisant le module template, vous pouvez tout à fait utiliser vos propres variables et les appeler dans vos fichiers de template. Pour en savoir sur ce module, cliquez [ici](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html).
Par défaut le fichier va prendre comme utilisateur propriétaire le nom de l'application et comme groupe propriétaire www-data (groupe nginx). Vous pouvez les changer en précisant des valeurs différentes.
- `src` est obligatoire. Il s'agit du répertoire où le fichier de template se situe sur la machine qui execute Ansible.
- `dest` est obligatoire. Il s'agit du répertoire où le fichier de template va être stocké.
- `type` est obligatoire. Si vous précisez comme valeur `script` alors le fichier de template aura pour droits 740 et il sera exécuté après son transfert sur le serveur Yunohost puis il sera supprimé.
Enfin, si votre fichier est un script, vous pouvez préciser son type (`type: "script"`). De cette manière, le fichier de script aura pour droits 740 et il sera exécuté après son transfert sur le serveur Yunohost puis il sera supprimé.
Pour `owner` et `group`, par défaut le fichier va prendre comme utilisateur propriétaire le nom de l'application et comme groupe propriétaire www-data (groupe NGINX). Vous pouvez les changer en précisant des valeurs différentes.
## Dépendances
......
......@@ -96,31 +96,38 @@ ynh_apps:
admin: user1
is_public: yes
post_install:
- src: "templates/file.sh.j2"
dest: "/tmp/script.sh"
- src: "templates/site_settings.yml.j2"
dest: "/var/www/discourse/config/site_settings.yml"
type: "config"
- src: "templates/configure_discourse.sh.j2"
dest: "/tmp/configure_discourse.sh"
type: "script"
owner: root
group: root
```
- `ynh_apps` is the list of applications to install.
- `label` allows you to give a custom name to the application on the user interface.
- `link` is the name of the Yunohost application to install.
**About the arguments:**
#### About the arguments:
- `domain` is essential. You have to choose one of the domains of your Yunohost instance.
- `path` is required. You have to choose a URL to access your application like `domain.tld/my_app`. Just use `/` if the application is to be installed on a subdomain.
- `is_public` argument is a common one. Set to `yes`, the application will be accessible to everyone, even without authentication to the Yunohost SSO portal. Set to `no`, the application will be accessible only after authentication.
For the other arguments, you have to refer to the `manifest.json` available in the repository of the Yunohost application you install. You can learn more about this part [here](https://yunohost.org/fr/packaging_apps_manifest).
**About the post-installation:**
It is possible to complete the installation of applications by adding configuration files or scripts written by yourself.
To enable this feature, define the `post_install` variable which corresponds to the post-installation files of your applications.
#### About the post-installation:
It is possible to complete the installation of applications by adding jinja template configuration files or scripts written by yourself.
To enable this feature, define the `post_install` variable which corresponds to the list of post-installation files of your applications.
Because this task uses the template module, you can use your own variables and call them in your template files. To know more about this module, click [here](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html).
By default the file will take as owner the name of the application and as owner www-data(nginx group). You can change them by specifying different values.
- `src` is mandatory. This is the directory where the template file is located on the machine running Ansible.
- `dest` is mandatory. This is the directory where the template file will be stored.
- `type` is mandatory. If you specify `script` as the value, then the template file will have 740 rights and will be executed after it is transferred to the Yunohost server and then deleted.
Finally, if your file is a script, you can specify its type (`type: "script"`). This way, the script file will have 740 permissions and will be run after it is uploaded to the Yunohost server then it will be deleted.
For `owner` and `group`, by default the file will take as owner the name of the application and as owner www-data(NGINX group). You can change them by specifying different values.
## Dependencies
......
......@@ -26,17 +26,17 @@
changed_when: False
# Post-installation part
- name: Transfer template to node (can be a config file or a script)
- name: Create post-install template
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: "{{ item.owner | default(ynh_app.link) }}"
group: "{{ item.group | default('www-data') }}"
mode: "{{ (item.type == 'script') | ternary('740', '640') }}"
mode: "{{ (item.type == 'script') | ternary('740', '660') }}"
loop: "{{ ynh_app.post_install|default([]) }}"
when: ynh_app.post_install
- name: Execute script if file type is a script then remove it
- name: Launch post-install script
ansible.builtin.command: "{{ ynh_app_post_install.dest }}"
args:
chdir: /tmp/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment