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