Ansible 2.2 Documentation 2.6
Total Page:16
File Type:pdf, Size:1020Kb
Ansible 2.2 Documentation 2.6 Ansible, Inc 10, 2018 Installation, Upgrade Configuration 1 About Ansible 1 1.1 Installation Guide............................................1 1.2 Configuring Ansible...........................................8 1.3 Ansible Porting Guides..........................................9 1.4 User Guide................................................ 42 1.5 Ansible Community Guide........................................ 270 1.6 Developer Guide............................................. 285 1.7 Cisco ACI Guide............................................. 354 1.8 Amazon Web Services Guide...................................... 363 1.9 Microsoft Azure Guide.......................................... 367 1.10 CloudStack Cloud Guide......................................... 375 1.11 Getting Started with Docker....................................... 382 1.12 Google Cloud Platform Guide...................................... 386 1.13 Using Ansible with the Packet host................................... 390 1.14 Rackspace Cloud Guide......................................... 396 1.15 Continuous Delivery and Rolling Upgrades............................... 410 1.16 Using Vagrant and Ansible........................................ 416 1.17 Getting Started with VMware...................................... 418 1.18 Ansible for VMware........................................... 419 1.19 Ansible for Network Automation.................................... 428 1.20 Ansible Galaxy.............................................. 473 1.21 YAML Syntax.............................................. 482 1.22 Python 3 Support............................................. 486 1.23 Testing Strategies............................................. 488 1.24 Frequently Asked Questions....................................... 492 1.25 Glossary................................................. 501 1.26 Ansible Tower.............................................. 506 1.27 Ansible Roadmap............................................ 506 i ii CHAPTER 1 About Ansible Ansible is an IT automation tool. It can configure systems, deploy software, and orchestrate more advanced IT tasks such as continuous deployments or zero downtime rolling updates. Ansible’s main goals are simplicity and ease-of-use. It also has a strong focus on security and reliability, featuring a minimum of moving parts, usage of OpenSSH for transport (with other transports and pull modes as alternatives), and a language that is designed around auditability by humans–even those not familiar with the program. We believe simplicity is relevant to all sizes of environments, so we design for busy users of all types: developers, sysadmins, release engineers, IT managers, and everyone in between. Ansible is appropriate for managing all envi- ronments, from small setups with a handful of instances to enterprise environments with many thousands of instances. Ansible manages machines in an agent-less manner. There is never a question of how to upgrade remote daemons or the problem of not being able to manage systems because daemons are uninstalled. Because OpenSSH is one of the most peer-reviewed open source components, security exposure is greatly reduced. Ansible is decentralized–it relies on your existing OS credentials to control access to remote machines. If needed, Ansible can easily connect with Kerberos, LDAP, and other centralized authentication management systems. This documentation covers the current released version of Ansible (2.5) and also some development version features. For recent features, we note in each section the version of Ansible where the feature was added. Ansible releases a new major release of Ansible approximately every two months. The core application evolves somewhat conservatively, valuing simplicity in language design and setup. However, the community around new modules and plugins being developed and contributed moves very quickly, adding many new modules in each release. Welcome to the Ansible Installation Guide! Introductory install guide text here. 1.1 Installation Guide Topics 1 Ansible 2.2 Documentation, 2.6 • Installation Guide – Basics / What Will Be Installed – What Version To Pick? – Control Machine Requirements – Managed Node Requirements – Installing the Control Machine * Latest Release via DNF or Yum * Latest Releases Via Apt (Ubuntu) * Latest Releases Via Apt (Debian) * Latest Releases Via Portage (Gentoo) * Latest Releases Via pkg (FreeBSD) * Latest Releases on Mac OSX * Latest Releases Via OpenCSW (Solaris) * Latest Releases Via Pacman (Arch Linux) * Latest Releases Via Pip * Tarballs of Tagged Releases * Running From Source – Ansible on GitHub Welcome to the Ansible Installation Guide! 1.1.1 Basics / What Will Be Installed Ansible by default manages machines over the SSH protocol. Once Ansible is installed, it will not add a database, and there will be no daemons to start or keep running. You only need to install it on one machine (which could easily be a laptop) and it can manage an entire fleet of remote machines from that central point. When Ansible manages remote machines, it does not leave software installed or running on them, so there’s no real question about how to upgrade Ansible when moving to a new version. 1.1.2 What Version To Pick? Because it runs so easily from source and does not require any installation of software on remote machines, many users will actually track the development version. Ansible’s release cycles are usually about four months long. Due to this short release cycle, minor bugs will generally be fixed in the next release versus maintaining backports on the stable branch. Major bugs will still have maintenance releases when needed, though these are infrequent. If you are wishing to run the latest released version of Ansible and you are running Red Hat Enterprise Linux (TM), CentOS, Fedora, Debian, or Ubuntu, we recommend using the OS package manager. For other installation options, we recommend installing via "pip", which is the Python package manager, though other options are also available. 2 Chapter 1. About Ansible Ansible 2.2 Documentation, 2.6 If you wish to track the development release to use and test the latest features, we will share information about running from source. It’s not necessary to install the program to run from source. 1.1.3 Control Machine Requirements Currently Ansible can be run from any machine with Python 2 (versions 2.6 or 2.7) or Python 3 (versions 3.5 and higher) installed (Windows isn’t supported for the control machine). This includes Red Hat, Debian, CentOS, macOS, any of the BSDs, and so on. : macOS by default is configured for a small number of file handles, so if you want to use 15 or more forks you’ll need to raise the ulimit with sudo launchctl limit maxfiles unlimited. This command can also fix any "Too many open files" error. : Please note that some modules and plugins have additional requirements. For modules these need to be satisfied on the ’target’ machine and should be listed in the module specific docs. 1.1.4 Managed Node Requirements On the managed nodes, you need a way to communicate, which is normally ssh. By default this uses sftp. If that’s not available, you can switch to scp in ansible.cfg. You also need Python 2 (version 2.6 or later) or Python 3 (version 3.5 or later). : • If you have SELinux enabled on remote nodes, you will also want to install libselinux-python on them before using any copy/file/template related functions in Ansible. You can use the yum module or dnf module in Ansible to install this package on remote systems that do not have it. • By default, Ansible uses the python interpreter located at /usr/bin/python to run its modules. However, some Linux distributions may only have a Python 3 interpreter installed to /usr/bin/python3 by default. On those systems, you may see an error like: "module_stdout":"/bin/sh: /usr/bin/python: No such file or directory\r\n" you can either set the ansible_python_interpreter inventory variable (see Working with Inventory) to point at your interpreter or you can install a Python 2 interpreter for modules to use. You will still need to set ansi- ble_python_interpreter if the Python 2 interpreter is not installed to /usr/bin/python. • Ansible’s "raw" module (for executing commands in a quick and dirty way) and the script module don’t even need Python installed. So technically, you can use Ansible to install a compatible version of Python using the raw module, which then allows you to use everything else. For example, if you need to bootstrap Python 2 onto a RHEL-based system, you can install it via $ ansible myhost --sudo -m raw -a "yum install -y python2" 1.1. Installation Guide 3 Ansible 2.2 Documentation, 2.6 1.1.5 Installing the Control Machine Latest Release via DNF or Yum On Fedora: $ sudo dnf install ansible On RHEL and CentOS: $ sudo yum install ansible RPMs for RHEL 7 are available from the Ansible Engine repository. To enable the Ansible Engine repository, run the following command: $ sudo subscription-manager repos --enable rhel-7-server-ansible-2.6-rpms RPMs for currently supported versions of RHEL, CentOS, and Fedora are available from EPEL as well as re- leases.ansible.com. Ansible version 2.4 and later can manage earlier operating systems that contain Python 2.6 or higher. You can also build an RPM yourself. From the root of a checkout or tarball, use the make rpm command to build an RPM you can distribute and install. $ git clone https://github.com/ansible/ansible.git $ cd ./ansible $ make rpm $ sudo rpm