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

Talk Python's Mastodon Michael Kennedy's Mastodon