Introduction to Ansible Transcripts
Chapter: Development Environment Configuration
Lecture: Configuring Ansible on Ubuntu

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Whether you're running Ubuntu Linux as your base operating system or your virtualizing it on top of Windows or Mac OS.
0:07 Ubuntu Linux provides a great environment to control Ansible. Let's first get Ansible installed, test it out
0:12 and then in the next video we'll create an SSH key that we'll use for the remainder of the course. I strongly recommend that you use
0:19 the latest version of Ubuntu which is currently 18.04 LTS as Bionic Beaver. This release will be supported for the next five years
0:27 and it comes with Python 3 pre-installed. So we can even skip a step because we will need Python installed on the system
0:33 in which we are going to control Ansible. Although Python 3 is`pre-installed we do need to install the venv package
0:40 so that we can work with virtual environments. There's two ways we could install Ansible on the system. We can install it site-wide
0:46 or we can use a virtual environment which is what I tend to prefer and what we're going to use in this video.
0:51 But before we can use a virtual environment also known as a virtualenv. We need to install the Python3-venv package.
1:03 Select 'Yes' that you want to continue. Then depending on the speed of your internet connection it should quickly install the package.
1:09 We can test out that everything worked by typing 'Python3 -m venv'. Let's create a directory to store our virtual envs. Go into it.
1:20 Then use our new venv package installation to create a virtual env called 'intro-ansible'. Then we can activate it.
1:28 That'd be source intro-ansible/bin/activate. Now we can see here by the change in our command prompt
1:34 that we're in the virtual env and it's been activated as our current Python installation. We no longer need superuser privileges
1:40 in order to install the Python package. I always prefer to run with the least amount of privileges on Linux when possible.
1:47 Just remember whenever you open a new term on a window you will have to run source intro-ansible/bin/activate in order to re-activate the virtual env.
1:54 Now we can use the pip command to install the latest version of Ansible. If you haven't installed any other dependencies on Ubuntu
2:10 you may see some errors about failing to build wheels for the Ansible dependencies. That shouldn't affect our ability to use Ansible.
2:16 But if it bothers you, there are a few development packages that you can install to get rid of that.
2:20 For now as long as you see 'successfully installed' and then the list of packages including Ansible we're good to go.
2:26 Let's test it out though to make sure that it's properly installed. We'll run our first Ansible ad-hoc command. So type 'ansible'.
2:34 Then we're just going to have placeholder for localhost. It's not actually going to use localhost it's going to fall back to localhost
2:40 when we try to run this ad-hoc command. -a for an ad-hoc command. We're going to run echo and just say something like 'hi'. for 'hello world'.
2:50 Make sure to have the single quotes around 'hello world' and then double quotes to end the ad-hoc command. We can test this out and we should see
2:58 success and 'hello world'. What this has done is it executed via Ansible the echo command on our localhost machine as an ad-hoc command.
3:07 This tells us Ansible is working and we'll be able to start creating our playbooks as soon as we create our SSH key.

Talk Python's Mastodon Michael Kennedy's Mastodon