Avatar

the setup

posted: Mon, Jun 12, 2023 | tagged: projects | dev | electronics | fec
return to project home | resources


getting started

Let's get our environment setup. All of the contents of these lessons assume a few things:

  • a vanilla install of one of the Ubuntu flavors (we're using Ubuntu Mate 22.04 LTS)
  • a local admin user
  • a willingness to get your hands dirty, and maybe deal with some "less-than-optimized" code (I'm using this as a learning opportunity too)

the kit

setup

Download and install your preferred version of Ubuntu desktop edition on a laptop or as a virtual machine. As of the time of this writing, I do not have an unattended installer for this process. But that is one of the many things I may develop over time.

Once your OS is up and running, you can then leverage the baseline configuration defined below (eventually this will be scripted). We'll be leveraging some bash scripting and Ansible to configure our environment. If you are unfamiliar, Ansible is a configuration management solution that can automate builds and configurations of systems. This provides for an idempotent environment from which we can work. If you have some chops with Ansible, you can go ahead and tweak the files in the repo to your liking.

baseline configuration

Please note, this is a non-production and not overly secure configuration. Use with appropriate caution.

Open your terminal application on Linux, and let's add your user to the visudo.

sudo visudo

At the end of the file, add the following line of code (replacing [your_username] with your logged in user account)

[your_username] ALL=(ALL) NOPASSWD: ALL

Save and close your file. Then close and relaunch your terminal and test executing a sudo command. If not prompted for a password, the configuration worked.

Next we'll generate a SSH key. Ansible will use this key to manage your host over a SSH connection. If you'd like a more in-depth guide for configuring the SSH key, Digital Ocean has a great write-up. But for quick and dirty, in your terminal, execute the following code:

ssh-keygen

Accept the defaults, you'll hit enter a few times. Then we'll quickly install open-ssh server.

sudo apt install openssh-server -y

Now we'll install the key locally with SSH so Ansible can do it's thing here shortly (replacing [your_username] with your logged in user account).

ssh-copy-id -i ~/.ssh/id_rsa.pub [your_username]@localhost

Now we'll install the Python package manager, Pip.

sudo apt install python3-pip -y

Now we can install Ansible.

pip3 install ansible

We'll make one edit to our terminal environment configuration file so we can execute Ansible tasks more easily. Edit your .bashrc file by opening the file for edit with a text editor:

nano ~/.bashrc

Now add the following line to the end of the file:

export PATH=$PATH:~/.local/bin

Save and exit the file. Our baseline configuration is done. We'll move on to installing packages and collecting files for use in our projects.

system configuration via Ansible

For the following to work, please clone files from this Github Repo

Navigate to where you saved the files from the repo. Within the ansible folder, you'll find a vars.yml file. Edit that file and replace my_username with your logged in user account. Please keep the account name in quotes. Save and close the file.

Look over the files in the tasks folder to see what they are doing. The code is commented, and is still a bit of a work in progress. As of the time of this writing, I'm not handling a few things as efficiently as I could. So please recommend any adjustments or corrections with a pull request.

From within your terminal, navigate to the main ansible folder and kick off the playbook as follows (use at your own risk!):

ansible-playbook -i inventory playbook.yml

This will take several minutes to execute. You can add the -v flag to see more verbose output while the playbook executes.

This ends the configuration and you're ready to start jumping into the lessons which you'll find back on the Friends in Electronics page.


return to project home

signature