Update README

This commit is contained in:
Nemo 2020-07-20 18:00:13 +02:00
parent 0f383d13ac
commit fd9cdc9680
2 changed files with 28 additions and 51 deletions

View file

@ -25,13 +25,16 @@ Download roles dependecies (currenty not used) :
```ansible-galaxy install -r requirements.yml -p ./roles/``` ```ansible-galaxy install -r requirements.yml -p ./roles/```
Copy the template inventory and edit the new file to add your node(s) in the corresponding `function` section and `os` section : Copy the template inventory folder and edit all subfiles to add your node(s) and other informations:
```bash ```bash
cp inventory_template.yml inventory_yourInventoryName.yml cp -R inventory_template inventory_yourInventoryName
vi inventory_yourInventoryName.yml
``` ```
> Note: you can create a dedicated private GIT repository to manage your inventory.
The main inventory file is: `inventory_yourInventoryName/inventory.yml`
Example with template values: Example with template values:
```bash ```bash
@ -69,27 +72,26 @@ all:
``` ```
> Note: the node's name needs to be reachable, you can use IP address or FQDN (recommended). > Note: the node's name needs to be reachable, you can use IP address or FQDN (recommended).
> WARNING : if you don't want to publish your inventory in the SCM system, add the filename in your .gitignore file (if you're using GIT).
Create a vault file for all nodes using the vault template file and define all values: Create a vault file for all nodes using the vault template file and define all values:
```bash ```bash
cp group_vars/all/vault.yml.template group_vars/all/vault.yml cp inventory_yourInventoryName/group_vars/vault.yml.template inventory_yourInventoryName/group_vars/vault.yml
vim group_vars/all/vault.yml vim inventory_yourInventoryName/group_vars/vault.yml
``` ```
Encrypt the vault file and check if edit function works. A prompt will ask you a password: Encrypt the vault file and check if edit function works. A prompt will ask you a password:
```bash ```bash
ansible-vault encrypt group_vars/all/vault.yml ansible-vault encrypt inventory_yourInventoryName/group_vars/vault.yml
ansible-vault edit group_vars/all/vault.yml ansible-vault edit inventory_yourInventoryName/group_vars/vault.yml
``` ```
> Note: if you version your code, don't forget to exclude this vault file of versionning (with .`gitignore file` if you are using GIT). > Note: if you version your code, don't forget to exclude this vault file of versionning (with .`gitignore file` if you are using GIT).
According to your needs, you can edit all variables in `group_vars` directory and subdirectories. According to your needs, you can edit all variables in `inventory_yourInventoryName/group_vars` directory and subdirectories.
You can also define host-specific variables (reboot/upgrade enable/disabe, cron hours, specific config, ...) in the host_vars directory (host.example.org is a commented example). Don't forget to update .gitignore if you don't want to publish some host vars. You can also define host-specific variables (reboot/upgrade enable/disabe, cron hours, specific config, ...) in the `inventory_yourInventoryName/host_vars` directory (host.example.org is an example). Don't forget to update .gitignore if you don't want to publish some host vars.
## Nodes preparation ## Nodes preparation
@ -133,7 +135,7 @@ exit
From the Ansible server (or your local machine), you can deploy specific playbooks using the following command: From the Ansible server (or your local machine), you can deploy specific playbooks using the following command:
```bash ```bash
ansible-playbook -i inventory_yourInventoryName.yml <playbook_name> --ask-vault-pass ansible-playbook -i inventory_yourInventoryName/inventory.yml <playbook_name> --ask-vault-pass
``` ```
> Notes: > Notes:

View file

@ -1,25 +0,0 @@
all:
vars:
ansible_user: ansible
ansible_become: yes
ansible_python_interpreter: auto_silent
children:
function:
children:
munin_server:
hosts:
myFirstGentooHost.example.org:
os:
children:
os_gentoo:
hosts:
myFirstGentooHost.example.org:
mySecondGentooHost.anotherexample.org:
os_debian:
hosts:
myFirstDebianHost.example.org:
mySecondDebianHost.anotherexample.org:
os_centos:
hosts:
myFirstCentOSHost.example.org:
mySecondCentOSHost.anotherexample.org: