Questions tagged [ansible-api]

Use this tag for questions regarding Ansible Python API.

Ansible Python API is a Python interface to Ansible allowing the control nodes, extending Ansible to respond to various python events, writing plugins, and connecting to external data sources.

26 questions
0
votes
0 answers

Ansible with aruba aoscx playbook and modules problems [solved]

I have some problems with ansible and aruba aoscx (model 8325),I did a simple installation with just a host and a playbook, they work for the vlan and banner config but when I want to do the interfaces there is a problem. So I searched on forums and…
Nsso
  • 1
  • 1
0
votes
0 answers

"--limit" option when calling playbook in Ansible python api

I am trying run playbook from withing python code however I do not know how to pass --limit option. It's similar to following How to set "--limit" option in Ansible playbook api ,however I think API has changed a bit. I have following…
0
votes
1 answer

How do I call Ansible Tower REST API endpoint to launch job_template for a job_template id?

I have Ansible Tower API version: 3.7.0 and Ansible version: 2.9.13. The documentation (attached image for reference) says that it supports a POST to api/v2/job_templates/id/launch/ in order to launch job template. However, when I call to the POST…
0
votes
1 answer

Ansible AXW ignores extra_vars

I want to launch a Job-Template via the AWX-API including some extra_vars, but every response I get has an empty extra_vars field. I already checked the documentation about…
xDevkas
  • 61
  • 2
  • 12
0
votes
1 answer

How to use Ansible python API to parse remote file and export json format

I would like to integrate Ansbile 2.9.9 python API with python 3.6.8 to sequentially parse each file (pt-mysql-summary.txt) on each host and export json format. Here is my ansible and python code. ansible-playbook -i hosts sum.yml sum.yml :…
kanpai
  • 25
  • 3
0
votes
2 answers

How to use Ansible 2.9.2 python API to execute tasks?

I am using Ansbile 2.9.2 python API and python 3.7.2 to get crontab information from servers in hosts file. I look through the Ansible API document, but the sample code only works for 'localhost'. here is my code api.py # !/usr/bin/python3 # -*-…
Crypto营长
  • 149
  • 3
  • 14
0
votes
1 answer

How to set an Ansible API tqm.run() timeout for MFA Users?

When 'ansible_user' is mistakenly set to an MFA user, tqm hangs indefinitely. I set a break point in 'task_queue_manager.py' here: play_return = strategy.run(iterator, play_context) But I can't find anything I can use to stop, end, or error out…
D.Fitz
  • 493
  • 5
  • 16
0
votes
1 answer

Ansible API save playbook callback to log file

I created a script to execute an Ansible playbook file: from StringIO import StringIO from ansible import context from ansible.cli import CLI from ansible.module_utils.common.collections import ImmutableDict from ansible.executor.playbook_executor…
Elad L.
  • 629
  • 1
  • 10
  • 25
0
votes
2 answers

Suppress ansible-playbook output

I am trying to run a playbook using Ansible 2.0 API inside python code. When I run the code, it prints the execution of playbook. Is there any way to suppress/hide those prints? def run_playbook(playbook, inventory, package, var_file_path,…
Jitu
  • 329
  • 1
  • 4
  • 16
0
votes
1 answer

How do I list hosts using Ansible 1.x API

Ansible-playbook has a --list-hosts cli switch that just outputs the hosts affected by each play in a playbook. I am looking for a way to access to same information through the python API. The (very) basic script I am using to test right now…
0
votes
1 answer

Programmatic ansible: save result into python variable

I am using this code to run ansible programmatically: https://github.com/jtyr/ansible-run_playbook with a simple playbook that just gathers facts from an Ubuntu server and prints them to the screen: - name: Test play hosts: all tasks: -…
renegadeofunk
  • 445
  • 1
  • 3
  • 11
1
2