Skip to main content

A simple SDK to use Ansible API.

Project description

ansible_simple

A simple SDK to use Ansible API.

usage

pip install ansible-simple

ansible module

from ansible_simple.api import AnsibleApi

a = AnsibleApi(remote_user="root", hosts=["192.168.13.109", "192.168.13.56"], remote_password={"conn_pass": "password"})
# a.run(module='shell', args='hostname')
# print(a.get_result())

ansible playbook

- name: mydbserver
  hosts: mydbserver
  gather_facts: no
  tasks:
    - name: uptime
      raw: uptime
      register: uptime
    - debug:
        msg: "{{ uptime.stdout }}"
    - name: online pm2 ls
      raw: ls
      register: ls
    - debug:
        msg: "{{ ls.stdout }}"
a.playbook(dynamic_inv={"mydbserver":["192.168.13.109", "192.168.13.56"]}, playbooks=['test.yml'])
# print(a.get_result())

reference

https://packaging.python.org/en/latest/tutorials/packaging-projects/
https://docs.ansible.com

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_simple-2.0.3.tar.gz (7.4 kB view hashes)

Uploaded Source

Built Distribution

ansible_simple-2.0.3-py3-none-any.whl (8.1 kB view hashes)

Uploaded Python 3

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