Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
basic:start [12/02/2021 15:34] dani |
— (Version actuelle) | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ====== Initial configuration ====== | ||
- | |||
- | ===== Clone our ansible-roles repo ===== | ||
- | |||
- | <code bash> | ||
- | git clone https:// | ||
- | cd ansible-roles | ||
- | </ | ||
- | |||
- | ===== Create the configuration directories ===== | ||
- | |||
- | Those directories will holds configurations of your hosts, groups etc. | ||
- | |||
- | <code bash> | ||
- | # This dir will contain your hosts inventories | ||
- | mkdir inventories | ||
- | # This one will contain vars for individual hosts | ||
- | mkdir host_vars | ||
- | # This one will contain vars for group of hosts | ||
- | mkdir group_vars | ||
- | # Will contain SSH related stuff | ||
- | mkdir ssh | ||
- | </ | ||
- | |||
- | ===== Create an SSH key pair ===== | ||
- | |||
- | The public key will have to be configured on the hosts you want to manage | ||
- | |||
- | <code bash> | ||
- | ssh-keygen -t rsa -b 4096 -f ssh/id_rsa | ||
- | </ | ||
- | <note important> | ||
- | |||
- | ===== Create your inventory file ===== | ||
- | This inventory will contains all the hosts you manage with ansible. You can have several inventories (eg, one per client). For example **inventories/ | ||
- | |||
- | <code ini> | ||
- | [fws] | ||
- | proxyin.fws.fr | ||
- | </ | ||
- | |||
- | ===== Setup the host to be managed ===== | ||
- | On the machine proxyin.fws.fr, | ||
- | * Create a user named ansible | ||
- | * Grant ansible full access to the system with sudo | ||
- | * Configure the public SSH key on this ansible user account | ||
- | |||
- | <code bash> | ||
- | useradd -m ansible | ||
- | mkdir ~ansible/ | ||
- | cat << | ||
- | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCj9d6jDy0m7xtqGfR0ywyXnq0lRfqqP0TzBhvCI4rcrJaDSLyA5/ | ||
- | _EOF | ||
- | chown -R ansible: | ||
- | chmod 700 ~ansible/ | ||
- | chmod 600 ~ansible/ | ||
- | cat << | ||
- | Defaults: | ||
- | ansible ALL=(ALL) NOPASSWD: ALL | ||
- | _EOF | ||
- | chmod 600 / | ||
- | </ | ||
- | |||
- | <note important> | ||
- | |||
- | ===== Connect a first time ===== | ||
- | The first time you connect, you have to validate the SSH host key, so, let's do it once, and check everything is OK | ||
- | |||
- | <code bash> | ||
- | ansible -m setup -i inventories/ | ||
- | </ | ||
- | |||
- | You should be prompted to accept the SSH key (which will be recorded in ssh/ | ||