From 9f85f58ac415859a68bf41288b78ee571a181ac5 Mon Sep 17 00:00:00 2001 From: Bertrand Lanson Date: Wed, 15 Mar 2023 23:12:05 +0100 Subject: [PATCH] edited readme, changed deault for prereqs --- README.md | 30 ++++++++++++++++++++++++++---- defaults/main.yml | 3 +-- tasks/main.yml | 2 +- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 74310e2..61c640d 100644 --- a/README.md +++ b/README.md @@ -11,17 +11,24 @@ None. Role Variables -------------- -Available variables are listed below, along with default values. A sample file for the default values is available in `default/hashicorp_consul.yml.sample` in case you need it for any `group_vars` or `host_vars` configuration. +Available variables are listed below, along with default values. A sample file for the default values is available in `default/manage_pip_packages.yml.sample` in case you need it for any `group_vars` or `host_vars` configuration. ```yaml -hashi_consul_install: true # by default, set to true +manage_pip_packages_install_prereqs: true # by default, set to true ``` -This variable defines if the consul package is to be installed or not before configuring. If you install consul using another task, you can set this to `false`. +```yaml +manage_apt_packages_list: # by default, not defined + - name: nginx + version_constraint: latest # Leaving empty or setting '' will be considered as latest + state: absent + - name: ... +``` +This variable is a list of packages, with their name, desired version and state. `version_constraint` can be multiple constraints,separatedby commas (example: `>1.10`, `>1.10,<1.15,!=1.12`,`==1.13`). Dependencies ------------ -This role requires both `ednxzu.manage_repositories` and `ednxzu.manage_apt_packages` to install consul. If you already installed consul, you can set `hashi_consul_install` to `false`, and that'll remove the dependencies. +This role requires `ednxzu.manage_apt_packages` to install python3 and pip. If you already installed python and pip, you can skip dependencies by setting `manage_pip_packages_install_prereqs` to `false`. Example Playbook ---------------- @@ -34,6 +41,21 @@ Including an example of how to use your role (for instance, with variables passe - ednxzu.manage_pip_packages ``` +```yaml +# calling the role inside a playbook and injecting variables (in another role for example) +- hosts: servers + tasks: + - name: "Install ansible with pip" + ansible.builtin.include_role: + name: ednxzu.manage_pip_packages + vars: + manage_pip_packages_install_prereqs: false + manage_pip_packages_list: + - name: ansible-core + version_constraint: latest + state: present +``` + License ------- diff --git a/defaults/main.yml b/defaults/main.yml index 48f5dee..566e0a0 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,7 +1,6 @@ --- # defaults file for manage_pip_packages -manage_pip_packages_install_python: true -manage_pip_packages_install_pip: true +manage_pip_packages_install_prereqs: true manage_pip_packages_list: - name: pip version_constraint: latest diff --git a/tasks/main.yml b/tasks/main.yml index 0e6a7d2..d170a81 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,7 +2,7 @@ # task/main file for manage_pip_packages - name: "Import prerequisites.yml" ansible.builtin.include_tasks: prerequisites.yml - when: manage_pip_packages_install_python + when: manage_pip_packages_install_prereqs - name: "Install/remove required packages" ansible.builtin.pip: