Skip to main content

ansible_please

image

Build Status

Documentation Status

Helper package to make running Ansible a bit smoother

  • Run Ansible tasks and playbooks from python with ease!

Installation

To install python package from pypi:

python -m pip install ansible-please

From source:

python setup.py install

To install ansible plugins, like docker_container

ansible-galaxy collection install community.docker

Overview

Main Components:

  • Inventory - Handles ansible inventory creation from input:

    • Basic input:
    hosts:
        master_host:
          - 'localhost'
    host_info:
      '127.0.0.1':
        'python_path': /usr/bin/python3
    
  • AnsibleTask - Handles individual ansible task creation

    • Docker Task creation
      from ansible_please.task_templates.docker_container import DockerContainer
      
      docker_container_task = DockerContainer(
        task_description="start-test-redis",
        name="test-redis",
        image="redis:latest",
      )
      
      • converts to yaml:
        - name: '[up] start-test-redis'
          docker_container:
            name: test-redis
            image: redis:latest
            user: nobody
            keep_volumes: false
            detach: true
            tty: false
            interactive: false
            network_mode: host
            container_default_behavior: compatibility
          tags:
          - up
        
    • up to start the container, down to tear it down
  • Playbook - Handles playbook creation

    from ansible_please.playbook import Playbook
    p = Playbook(name="Set up master_host",
               hosts="master_host",
               tasks=[docker_container_task.up(), docker_container_task.down()])
    
    • converts to yaml:
      - name: Set up master_host
        hosts: master_host
        gather_facts: true
        tasks:
        - name: '[up] start-test-redis'
          docker_container:
            name: test-redis
            image: redis:latest
            user: nobody
            keep_volumes: false
            detach: true
            tty: false
            interactive: false
            network_mode: host
            container_default_behavior: compatibility
          tags:
          - up
        - name: '[down] start-test-redis'
          docker_container:
            name: test-redis
            state: absent
            user: nobody
            keep_volumes: false
            detach: true
            tty: false
            interactive: false
            network_mode: host
            container_default_behavior: compatibility
          tags:
          - down
      
  • AnsibleRunner - main handler for running playbooks

    r = AnsibleRunner(playbook=p, input_path="test_input.yml") # or pass in Inventory class
    r.up()
    

See full examples

Free software: MIT license

Documentation: https://ansible-please.readthedocs.io.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2020-12-22)

  • First release on PyPI.

Metadata

Release files for ansible-please 0.1.20

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ansible-please 0.1.20
File Size Uploaded Provenance Actions
ansible_please-0.1.20.tar.gz 20.5 kB Without provenance Details for ansible_please-0.1.20.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for ansible-please 0.1.20
File Interpreter ABI Platform Actions
ansible_please-0.1.20-py3.9.egg Legacy Egg format - - Details for ansible_please-0.1.20-py3.9.egg
ansible_please-0.1.20-py2.py3-none-any.whl Python 3, Python 2 none any Details for ansible_please-0.1.20-py2.py3-none-any.whl

Total release size: 65.6 kB

Release files / ansible_please-0.1.20.tar.gz

Download URL ansible_please-0.1.20.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
61ad1e23165bc5b52622dc400694bf33508e3b47a3792648eca33c0a5e672fc9
BLAKE2b-256 checksum
How to use checksums
9b948427704a3630f83ebce8bbf4da1c78a02f0805aa4fdc445d11b3cefff091
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

Release files / ansible_please-0.1.20-py3.9.egg

Download URL ansible_please-0.1.20-py3.9.egg
Size 30.0 kB
Tags Egg
SHA-256 checksum
How to use checksums
2da50bbe75f69777c4d856caeb1353d0508e57990238b5361234404ff76b278f
BLAKE2b-256 checksum
How to use checksums
c9a460e10195b4df37665ce8b2d81d3777219a77e5bbc9b5e4e7f5f184f529a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

Release files / ansible_please-0.1.20-py2.py3-none-any.whl

Download URL ansible_please-0.1.20-py2.py3-none-any.whl
Size 15.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
d11a7d1ce5745612627c44271f66a9f0bd5a13501fdbdc8b69866c949e3461c0
BLAKE2b-256 checksum
How to use checksums
1cefb5f1c8ac6b00e47ec447ace9f175f444ea7927636f257c4eaf325436f8de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

Security for ansible-please 0.1.20

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page