Basics about using Semaphore UI
Setting up Semaphore UI to run simple Ansible Playbooks
Repositories
Go to the Repositories tab on the right and click on NEW REPOSITORY.
Choose a name that you like, for me I choose USER REPOSITORY BRANCH
Then add the URL (I recommend using HTTPS for this) to URL or path.
Select your Branch like for example master or development and if it's a public Repository click none when selecting the Access Key.
Key Store
For all of the following options, select Key Store from the right and click on NEW KEY on the top right.
SSH User
Give it a name and on type select Login with password.
Enter the username and password and that's already it.
sudo
Same as above with SSH User, just make sure to not type a username since it won't work them for some stupid reason.
SSH-Key
First create a dedicated SSH-Key on your local machine with the following command:
ssh-keygen -t ed25519 -a 100
Make sure to give it a proper password. Then, select SSH Key when creating a new key in Semaphore UI and give it the username of the server you're gonna connect to, the passphrase of the key and then paste the private key content. To view it, just use the following command:
cat ~/.ssh/yourkey
It's important to choose the key without aa .something filetype since that's the private key that we need.
Inventory
Select inventory from the right and then click on NEW INVENTORY. Give it a name, select the user and sudo credentials we just created and choose Type static. From there, enter the informations that you need. A simply inventory would look like this:
[arch]
nb01 192.168.0.10
nb02 192.168.0.11
nb03 192.168.0.12
[debian]
srv01 192.168.0.20
srv02 192.168.0.21
[rhel]
pc01 192.168.0.30
Task Templates
Now that we have taken all the steps needed to run a playbook, let's create our first Job.
Go to Task Template and select Ansible Playbook under NEW TEMPLATE.
Give it a name and then point to the path to your playbook inside the Repo like installation/tailscale.yml
Choose the correct Inventory and Repo.
If you declared variables, don't forget to add them in the Variable Group fieled.
To see how you can do that, follow the steps in the next chapter.
Click create and you'll see your Job.
Just click und the run button next to the name and select whatever you need in the new popup.
In my Homelab, when I tested the playbook before and I know it'll work, I select nothing and just click on RUN.
That's it, now your Playbook is running and you can go to grab a coffee. Enjoy automating!
Passing Secrets and Variable through
First, we go to Variable Groups since our "Vault" will be in there. We then createa a new group and enter a new name. I tested it with my tailscale installation playbook, so as for the name I choose Tailscale. Now you can add extra and Enviroment Variables, but that won't work with secrets. For that, we go to the Secrets Tab. Since I needed the auth-key from tailscale and decalared that in my playbook as the variable TAILTOKEN, I simply created a new Extra variables. TAILTOKEN in the name field and in the password field I entered the AUTH-Key I created within Tailscale. Saved it and I was done. Executed the Playbook and verified that the VPN was up. And that's it, now you know how to pass variables and secrets through.