refs #8025 README install improved, added local inventory

This commit is contained in:
Juan Ferrer 2024-10-04 08:35:07 +02:00
parent 6d68f76434
commit c30bfd3ee5
2 changed files with 17 additions and 9 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
.vault.yml .vault.yml
.passbolt.yml .passbolt.yml
venv venv
inventories/local

View File

@ -4,12 +4,16 @@ Collection of Ansible playbooks used in the Verdnatura server farm.
## Setup Ansible ## Setup Ansible
Install Ansible on Debian. ### Debian
Install Ansible package.
``` ```
apt install ansible apt install ansible
``` ```
Create Python virtual environment. ### Python
Create a Python virtual environment.
``` ```
python3 -m venv venv python3 -m venv venv
source venv/bin/activate source venv/bin/activate
@ -17,11 +21,6 @@ pip install --upgrade pip ansible==10.1.0 ansible-builder==3.1.0
pip install -r requirements.txt pip install -r requirements.txt
``` ```
Install dependencies.
```
ansible-galaxy collection install -r collections/requirements.yml
```
Before running any Ansible command, activate the Python virtual environment. Before running any Ansible command, activate the Python virtual environment.
``` ```
source venv/bin/activate source venv/bin/activate
@ -32,14 +31,22 @@ Once you're done, deactivate the virtual environment.
deactivate deactivate
``` ```
### All platforms
Install dependencies.
```
ansible-galaxy collection install -r collections/requirements.yml
```
## Run playbook ## Run playbook
Before merging changes into protected branches, playbooks should be tested Before merging changes into protected branches, playbooks should be tested
locally to ensure they work properly. locally to ensure they work properly. The *local* inventory can also be used,
wich is not uploaded to the repository.
Run playbook on inventory host. Run playbook on inventory host.
``` ```
ansible-playbook -i inventories/lab -l <host> [-t tag1,tag2...] playbooks/ping.yml ansible-playbook -i inventories/local -l <host> [-t tag1,tag2...] playbooks/ping.yml
``` ```
Run playbook on the fly on a host not declared in the inventory. Run playbook on the fly on a host not declared in the inventory.