ansible-pull – Pull ansible playbooks from a VCS repo and executes them for the local host

“ansible-pull” is a versatile command-line tool provided by Ansible that allows users to pull Ansible playbooks from a Version Control System (VCS) repository and execute them for the local host. It simplifies the process of running Ansible playbooks on a target machine by automatically fetching the necessary configuration files from a VCS repository.

Here are the key features and functionalities of ansible-pull:

  • Playbook Retrieval: ansible-pull retrieves Ansible playbooks from a VCS repository, such as Git, Mercurial, or Subversion. Instead of pushing configurations to target machines, ansible-pull enables the target machine to pull the playbook and execute it locally. This approach is particularly useful for managing configurations on a single machine or a small group of machines.
  • Local Execution: With ansible-pull, the target machine itself becomes the control machine, executing the playbook locally. This eliminates the need for a centralized control machine and allows for self-contained automation on individual hosts. It is especially beneficial in scenarios where a distributed approach is preferred or when managing local configurations.
  • Pull Interval and Scheduling: ansible-pull offers flexibility in defining the frequency at which the playbook is pulled from the VCS repository. Users can set the pull interval to execute the playbook periodically or schedule it to run at specific times. This feature allows for automation updates, ensuring that the target machine always has the latest configurations.
  • Dynamic Inventory: ansible-pull supports dynamic inventory management. Users can configure the playbook to fetch the inventory dynamically, allowing for the inclusion of the local host in the inventory or retrieving dynamic inventory data from external sources. This enables dynamic configuration management based on the specific characteristics of the target machine.
  • Local Configuration Updates: ansible-pull simplifies the process of updating configurations on the target machine. Users can make changes to the playbook in the VCS repository, and when ansible-pull is executed on the target machine, it automatically pulls the updated playbook and applies the new configurations. This makes it easy to manage and distribute configuration updates across multiple hosts.
  • Reporting and Output: ansible-pull provides detailed reporting and output options. Users can specify the verbosity level to control the amount of information displayed during playbook execution. This facilitates troubleshooting and provides visibility into the automation process on the local host.
  • Integration with VCS Systems: ansible-pull seamlessly integrates with popular Version Control Systems like Git, Mercurial, and Subversion. Users can configure ansible-pull to pull playbooks from their preferred VCS repository, leveraging the powerful versioning and collaboration features provided by these systems.

ansible-pull simplifies the execution of Ansible playbooks on a local host by enabling the host to pull the playbook from a VCS repository and apply the configurations locally. It offers flexibility in scheduling, supports dynamic inventory, and streamlines the process of updating configurations. With ansible-pull, users can easily manage and automate local configurations, making it a valuable tool for self-contained automation scenarios or managing configurations on individual machines.

ansible-pull Command Examples

1. Pull a playbook from a VCS and execute a default local.yml playbook:

# ansible-pull -U repository_url

2. Pull a playbook from a VCS and execute a specific playbook:

# ansible-pull -U repository_url playbook

3. Pull a playbook from a VCS at a specific branch and execute a specific playbook:

# ansible-pull -U repository_url -C branch playbook

4. Pull a playbook from a VCS, specify hosts file and execute a specific playbook:

# ansible-pull -U repository_url -i hosts_file playbook
Related Post