Quick Setup
Note
This setup guide assumes you are using mise.
You only have to do this setup once when you first clone the repository. After that, you can just edit the existing SSH config and inventories to add hosts.
- Trust & install
misefile and source Direnv.envrc:
| Mise, direnv, go-task/task setup | |
|---|---|
- Create SSH keys
- If you already have a key you've copied to the remote host(s) you want to manage, you can copy that into the
.ssh/directory and use that key instead of creating a new one.
- Copy the example SSH config
./.ssh/example_configto a new file:cp .ssh/example_config .ssh/config- Edit this file with your host(s), using the included example as a reference
Note
After copying the example inventory and group_vars/all.yml files, make sure to edit them with the data for your host/SSH keys/etc.
- Create your onboarding inventory
- Start by copying
inventories/onboard/example.inventory.ymltoinventories/onboard/inventory.ymlandinventories/onboard/group_vars/example.all.ymltoinventories/onboard/group_vars/all.yml.- This inventory assumes you can connect to the remote with a password or your host's
id_rsaSSH key. - The
plays/onboard/run-onboarding.ymlplaybook will create theansible_svcuser on the remote host and copy the.ssh/ansible_sshSSH key you created. - Use the example hosts as a reference to add the hosts you want to manage with Ansible.
- This inventory assumes you can connect to the remote with a password or your host's
- Run the onboarding playbook, using
-kto prompt for connection password if you have not already copied an SSH key to connect to the remote host:
- Start by copying
| Run onboarding playbook | |
|---|---|
-
Create the main/"homelab" inventory
- Copy
inventories/homelab/example.inventory.ymltoinventories/homelab/inventory.ymlandinventories/homelab/group_vars/example.all.ymltoinventories/homelab/group_vars/all.yml - Add the host(s) from your onboarding inventory, removing any
ansible_useroransible_ssh_private_keyvars.
- Copy
-
Test the new inventory by running the
plays/ping.ymlplaybook:
| Run ping playbook | |
|---|---|
If the setup was done correctly, you should be able to ping the remote host using the ansible_svc SSH key.