Skip to main content

Helper package to make running Ansible a bit smoother

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ansible_please-0.1.20.tar.gz (20.5 kB view details)

Uploaded Source

Built Distributions

ansible_please-0.1.20-py3.9.egg (30.0 kB view details)

Uploaded Source

ansible_please-0.1.20-py2.py3-none-any.whl (15.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file ansible_please-0.1.20.tar.gz.

File metadata

  • Download URL: ansible_please-0.1.20.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for ansible_please-0.1.20.tar.gz
Algorithm Hash digest
SHA256 61ad1e23165bc5b52622dc400694bf33508e3b47a3792648eca33c0a5e672fc9
MD5 de992caaac42a589622dd25949876dba
BLAKE2b-256 9b948427704a3630f83ebce8bbf4da1c78a02f0805aa4fdc445d11b3cefff091

See more details on using hashes here.

File details

Details for the file ansible_please-0.1.20-py3.9.egg.

File metadata

  • Download URL: ansible_please-0.1.20-py3.9.egg
  • Upload date:
  • Size: 30.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for ansible_please-0.1.20-py3.9.egg
Algorithm Hash digest
SHA256 2da50bbe75f69777c4d856caeb1353d0508e57990238b5361234404ff76b278f
MD5 2d8f8cd2c2aa74075128e0654b5f2746
BLAKE2b-256 c9a460e10195b4df37665ce8b2d81d3777219a77e5bbc9b5e4e7f5f184f529a9

See more details on using hashes here.

File details

Details for the file ansible_please-0.1.20-py2.py3-none-any.whl.

File metadata

  • Download URL: ansible_please-0.1.20-py2.py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using 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

File hashes

Hashes for ansible_please-0.1.20-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d11a7d1ce5745612627c44271f66a9f0bd5a13501fdbdc8b69866c949e3461c0
MD5 3d719b8b354aca69d65c3a69e1c91eb5
BLAKE2b-256 1cefb5f1c8ac6b00e47ec447ace9f175f444ea7927636f257c4eaf325436f8de

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page