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

Login or purchase this course to watch this video and the rest of the course contents.
0:00 If you're working on Mac
0:01 then we'll get you to the exact point you need
0:03 in order to run Ansible.
0:04 If you're working on Linux or Windows
0:06 feel free to skip this video
0:07 and go to the appropriate video
0:08 for your operating system.
0:09 We're going to use Python 3 to run Ansible.
0:11 So the first step is to go to
0:14 in your browser. Click downloads.
0:16 Download Python 3.6.5
0:18 or whatever the latest release is.
0:20 Luckily, other than the Python 2, Python 3 split
0:22 whatever the latest Python version is that's out there
0:25 should be able to work just fine with this.
0:27 And if not, let me know, and I'll update the videos.
0:29 Click on the package and install it.
0:39 You'll need to type in your password
0:40 for root privileges.
0:41 That's normal with installing Python.
0:43 Once it's all done, click close
0:44 and you can move it to trash, the installer.
0:46 Now we need to test it out and install Ansible.
0:48 Open up a new finder window.
0:49 Click applications and then scroll all the way
0:51 to the bottom to utilities.
0:53 We're going to work on the command line
0:54 so you need to open the terminal window.
0:56 Assuming Python 3 has installed correctly
0:58 we can type python3
1:00 and we should see the appropriate version
1:01 that we installed on our system.
1:03 Don't just type python
1:04 because that will go to the default system installation.
1:06 We really want to work with Python 3
1:08 so use the python3 command.
1:10 It's good practice to use a virtual environment
1:13 that's included as part of the core Python installation.
1:15 I have a directory called envs
1:19 where I keep all of my virtual environments.
1:20 And to create a new virtual environment
1:22 type "python3 -m venv" and then we give it a name.
1:27 In this case, we'll just call it intro-ansible.
1:29 To activate that virtual env
1:31 type source and then the directory
1:35 bin/activate.
1:37 We can tell that it's been activated
1:38 by the parentheses and the name
1:40 of the virtual env that we're now working with.
1:41 Now we can use the pip command, so P-I-P.
1:44 Pip allows us to install packages
1:46 and if we type pip freeze right now
1:48 we will see that we don't have any packages
1:50 installed in this virtual env.
1:52 Type pip install ansible, and this will go out
1:55 and grab the Ansible package from PyPI.
2:02 Give it a couple minutes
2:03 and we should see successfully installed
2:05 and then a bunch of packages.
2:06 These packages are the dependencies
2:08 that are used by Ansible.
2:09 For example, Jinja is used for templates.
2:11 Paramiko is used for the underlying SSH protocol.
2:15 PyYAML is used for the YAML files in our playbooks.
2:18 And of course we see the Ansible package itself.
2:20 Now we can test out whether Ansible
2:22 has been installed correctly.
2:23 We'll run a command against localhost.
2:25 This is an ad-hoc Ansible command.
2:30 ansible localhost, for the system we want to run it against
2:33 -a, for an ad-hoc command
2:35 and we're just going to run an echo command that says hi.
2:38 Press return.
2:39 We'll get some warnings that tell us
2:40 we don't have a host file, but that's okay.
2:42 It's going to default to a localhost
2:43 and then we'll see the output "hi"
2:45 from the successful execution
2:46 of our Ansible ad-hoc command.
2:48 This tells us Ansible has been successfully installed
2:50 and now we'll be ready to write our playbooks.