5 minutes
Home Ansible Setup
Setting Ansible for My Home Lab
Since the weather was so nice I figured it would be a great idea to take the day off and work on my home lab. To start off I know that I am pretty comfortable with Ansible so I’d like to use that to build it all out. One thing that always bugged me was the directory structure. The first time I invested a lot into Ansible I went with the Alternative Directory Layout and it made things harder to leverage something across my environment. Since then I’d like to think that I have matured and learned from my mistakes. I have also begun to understand the value and importance of a monorepo so I am going to go with the standard Directory Layout:
Adding a User
First off I created a new role for the purose of adding a user. I added my user, added a public key, and granted sudo privilege.
Adding the Role to a Playbook
Then I took that role and incorporated to a playbook called common
. The idea is that this is something that would want to do to any server in the lab.
Adding the Hosts to a Group
Finally I created entries for my hosts and then added the newest ones to a that I could easily target for this common playbook run against:
Execute the Playbook
Now I am able to run the playbook (I ran it a few times before so I don’t expect changes) to make sure things are in the state that I expect:
Trying It Out
If all went as expected then I should be able to ssh right to the host and then run a sudo
command.
Success!