GithubHelp home page GithubHelp logo

ansible / ansible-runner Goto Github PK

View Code? Open in Web Editor NEW
937.0 48.0 347.0 2.42 MB

A tool and python library that helps when interfacing with Ansible directly or as part of another system whether that be through a container image interface, as a standalone tool, or as a Python module that can be imported. The goal is to provide a stable and consistent interface abstraction to Ansible.

License: Other

Python 99.87% Dockerfile 0.13%

ansible-runner's Introduction

Ansible Runner

PyPi Documentation Code of Conduct Ansible Mailing lists codecov

Ansible Runner is a tool and Python library that helps when interfacing with Ansible directly or as part of another system. Ansible Runner works as a standalone tool, a container image interface, or a Python module that can be imported. The goal is to provide a stable and consistent interface abstraction to Ansible.

See the latest documentation for usage details.

Get Involved

ansible-runner's People

Contributors

akasurde avatar alancoding avatar ansible-zuul[bot] avatar ashwini-mhatre avatar beeankha avatar benthomasson avatar chrismeyersfsu avatar dependabot[bot] avatar ganeshrn avatar ghjm avatar gundalow avatar jbradberry avatar jctanner avatar kdelee avatar matburt avatar maxamillion avatar mnecas avatar mtucker502 avatar nitzmahone avatar pabelanger avatar radez avatar ryanpetrello avatar samdoran avatar shanemcd avatar shrews avatar sivel avatar softwarefactory-project-zuul[bot] avatar spredzy avatar wenottingham avatar wwitzel3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-runner's Issues

Role name is included in playbook tasks after a role.

In the message data the role name is included for tasks after a role for roles in a play or include_role.

The pause_for_kernel task is not part of the hello role. It was run after the hello role.

Role was still set to hello:

                 u'role': u'hello',

Playbook:

- gather_facts: false
  hosts: localhost
  roles:
  - ansible_kernel_helpers
  - hello
  tasks:
  - pause_for_kernel:
      host: 127.0.0.1
      port: 50675
      task_num: 0
  - include_tasks: next_task1.yml

Message:

{'counter': 23,
 u'created': u'2018-08-06T20:02:58.849839',
 'end_line': 31,
 u'event': u'playbook_on_task_start',
 u'event_data': {u'is_conditional': False,
                 u'name': u'pause_for_kernel',
                 u'pid': 77031,
                 u'play': u'localhost',
                 u'play_pattern': u'localhost',
                 u'play_uuid': u'9801a79a-dd33-c9e6-7a97-000000000006',
                 u'playbook': u'playbook.yml',
                 u'playbook_uuid': u'44730e6f-e077-4ad0-bd00-a819c7fcaaf8',
                 u'role': u'hello',
                 u'task': u'pause_for_kernel',
                 u'task_action': u'pause_for_kernel',
                 u'task_args': u'task_num=1, host=127.0.0.1, port=50675',
                 u'task_path': u'/private/var/folders/p8/mttm7w913kq_v0wyfl9khlpc0000gn/T/ansible_kernel_playbookXmz9Pj/project/next_task1.yml:4',
                 u'task_uuid': u'9801a79a-dd33-c9e6-7a97-00000000002c'},

Executing runner in the background doesn't work properly

Hello,

I am trying:
https://ansible-runner.readthedocs.io/en/latest/standalone.html#executing-runner-in-the-background

I have just a simple testing role:

---
- name: simulate long running op (120 sec), wait for up to 400 sec, poll every 5 sec
  command: /bin/sleep 120
  async: 400
  poll: 5

So running this as ansible-runner start /tmp/ansible-runner20180726-13642-1i9ck95 --json -i result --hosts localhost ...

I can see the python processes running this but:

  1. ansible-runner is-alive /tmp/ansible-runner20180726-13642-1i9ck95 -i result doesn't do anything, returns blank string
  2. ansible-runner stop /tmp/ansible-runner20180726-13642-1i9ck95 -i result doesn't stop the work, I still see the processes running
  3. Unclear status. It fails for a reason I can't find (last event is running this play, then nothing). And it gives inconsistent result. status file has failed in it, but rc file has None

Fix up -partial.json job event files and include cardinality

They include the partial tag because we don't have memcached available to do event reassembly with the stdout. Need to figure out how to work around that.

We should also include some sort of cardinality representation to see which events came first.

convert ansible-runner cli to subcommands

The current implementation of ansible-runner CLI uses positional arguments to infer actions to be taken. While this worked for the initial releases of ansible-runner, subsequent new features such as running roles directly is starting to cause confusion with regards to which command line options apply to which scenarios. This situation will only get worse as more features are added to ansible-runner.

Below is a proposed CLI structure that implements sub commands instead of positional arguments where each sub command can maintain its own set of arguments in additional to any global arguments that will be supported for all options.

ansible-runner run <private_data_dir> [options]
ansible-runner start <private_data_dir> [options]
ansible-runner stop <privateip_data_dir>
ansible-runner is-alive <private_data_dir>
ansible-runner role <role_name> [options]

Global options to be applied to all subcommands

--version
--json
--quiet
--debug
--logfile
--artifact-dir
-v

Playbook options to be applied to run, start and role

--hosts
--ident
--inventory
--cmdline

Playbook only options to be applied to 'role'

--vars (currently role-vars)
--skip-facts (currently role-skip-facts)
--path (currently roles-path)

Options that would be removed since they are no longer needed

--playbook
--role

Please provide any feedback / thoughts / ideas about this proposal.

eventlet 0.20.0 and newer doesn't work with ansibler-runner

ansible-runner uses pexpect that uses poll() for child processes monitoring. select.poll() has been removed from eventlet in 0.20.0 and projects like OpenStack that use eventlet monkey_patching cannot use ansible-runner.

2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking Traceback (most recent call last):
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking File "/opt/stack/networking-ansible/networking_ansible/ansible_networking.py", line 129, in vlan_access_port
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking segmentation_id, switch_port)
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking File "/opt/stack/networking-ansible/networking_ansible/ansible_networking.py", line 75, in run_task
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking inventory=self.inventory)
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking File "/usr/lib/python2.7/site-packages/ansible_runner/interface.py", line 94, in run
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking r.run()
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking File "/usr/lib/python2.7/site-packages/ansible_runner/runner.py", line 105, in run
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking searchwindowsize=100)
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking File "/usr/lib/python2.7/site-packages/pexpect/spawnbase.py", line 341, in expect
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking timeout, searchwindowsize, async
)
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking File "/usr/lib/python2.7/site-packages/pexpect/spawnbase.py", line 369, in expect_list
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking return exp.expect_loop(timeout)
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking File "/usr/lib/python2.7/site-packages/pexpect/expect.py", line 111, in expect_loop
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking incoming = spawn.read_nonblocking(spawn.maxread, timeout)
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking File "/usr/lib/python2.7/site-packages/pexpect/pty_spawn.py", line 468, in read_nonblocking
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking r = poll_ignore_interrupts([self.child_fd], timeout)
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking File "/usr/lib/python2.7/site-packages/pexpect/utils.py", line 166, in poll_ignore_interrupts
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking poller = select.poll()
2018-07-11 15:15:45.604 TRACE networking_ansible.ansible_networking AttributeError: 'module' object has no attribute 'poll'

How to control verbosity from python

I tried the latest HEAD and I am getting the following with the demo (with the python commands in the readme):

image

I would like to see the full traceback.
As a sidenote, I have psutil installed:
image
And can even run commands with it:
image

Standard events no longer received on event_handler (1.0.5)

This commit a009197 causes the reconstructed events on the event_handler to be lost. Only partial events are available.

Before this commit I received events like this:

{'counter': 23,
 u'created': u'2018-08-06T20:02:58.849839',
 'end_line': 31,
 u'event': u'playbook_on_task_start',
 u'event_data': {u'is_conditional': False,
                 u'name': u'pause_for_kernel',
                 u'pid': 77031,
                 u'play': u'localhost',
                 u'play_pattern': u'localhost',
                 u'play_uuid': u'9801a79a-dd33-c9e6-7a97-000000000006',
                 u'playbook': u'playbook.yml',
                 u'playbook_uuid': u'44730e6f-e077-4ad0-bd00-a819c7fcaaf8',
                 u'role': u'hello',
                 u'task': u'pause_for_kernel',
                 u'task_action': u'pause_for_kernel',
                 u'task_args': u'task_num=1, host=127.0.0.1, port=50675',
                 u'task_path': u'/private/var/folders/p8/mttm7w913kq_v0wyfl9khlpc0000gn/T/ansible_kernel_playbookXmz9Pj/project/next_task1.yml:4',
                 u'task_uuid': u'9801a79a-dd33-c9e6-7a97-00000000002c'},

After this commit I receive events like this:

{'counter': 15,
 'end_line': 16,
 'start_line': 15,
 'stdout': u'\x1b[0;32mok: [localhost]\x1b[0m',
 u'uuid': u'6365cd14-fca4-4515-b32a-2bd3b118491c'}
{'counter': 16,
 'end_line': 18,
 'start_line': 16,
 'stdout': u'\r\nTASK [include_tasks] ***********************************************************',
 u'uuid': u'9801a79a-dd33-7cb8-160d-00000000000c'}
{'counter': 17,
 'end_line': 18,
 'start_line': 18,
 'stdout': '',
 u'uuid': u'9cca7d64-ad6b-4138-a66b-2b7c941d831a'}
{'counter': 18,
 'end_line': 19,
 'start_line': 18,
 'stdout': u'\x1b[0;36mincluded: /private/var/folders/p8/mttm7w913kq_v0wyfl9khlpc0000gn/T/ansible_kernel_playbookAuybIf/project/next_task0.yml for localhost\x1b[0m',
 u'uuid': u'047735ba-01dd-41bc-a471-70c3b8ae3bf1'}
{'counter': 19,
 'end_line': 21,
 'start_line': 19,
 'stdout': u'\r\nTASK [debug] *******************************************************************',
 u'uuid': u'9801a79a-dd33-7cb8-160d-000000000020'}
{'counter': 20,
 'end_line': 24,
 'start_line': 21,
 'stdout': u'\x1b[0;32mok: [localhost] => {\x1b[0m\r\n\x1b[0;32m    "msg": "hi"\x1b[0m\r\n\x1b[0;32m}\x1b[0m',
 u'uuid': u'd9530564-e8f8-4104-a0ab-55cecb3f82e2'}
{'counter': 21,
 'end_line': 26,
 'start_line': 24,
 'stdout': u'\r\nTASK [pause_for_kernel] ********************************************************',
 u'uuid': u'9801a79a-dd33-7cb8-160d-000000000021'}

This appears to be the problem from ansble_runner/runner.py:

@@ -37,6 +37,11 @@ class Runner(object):
         later use
         '''
         if 'uuid' in event_data:
+            should_write = True
+            if self.event_handler is not None:
+                should_write = self.event_handler(event_data)
+            if not should_write:
+                return
             filename = '{}-partial.json'.format(event_data['uuid'])
             partial_filename = os.path.join(self.config.artifact_dir,
                                             'job_events',
@@ -53,8 +58,6 @@ class Runner(object):
                     json.dump(event_data, write_file)
                 if self.remove_partials:
                     os.remove(partial_filename)
-                if self.event_handler is not None:
-                    self.event_handler(event_data)
             except IOError as e:
                 debug("Failed writing event data: {}".format(e))
 

Event handler is called too early. The additional data for the event is not being copied into the event data structure.

Implement ad-hoc interface

Allowing giving module and args to the ansible-runner utility and the run() and run_async() methods to invoke an ad-hoc ansible command.

Can't use relative path as private data dir

$ ansible-runner run ./demo --playbook test.yml
Ident: 7f12bc40-b806-4a70-aa39-8d9bc1ae3305
Hosts: ./demo/inventory
Playbook: test.yml
 [WARNING]: Unable to parse /root/Development/ansible-
runner/demo/project/demo/inventory as an inventory source
 [WARNING]: No inventory was parsed, only implicit localhost is available
 [WARNING]: provided hosts list is empty, only localhost is available. Note
that the implicit localhost does not match 'all'
Traceback (most recent call last):
  File "/bin/ansible-playbook", line 146, in <module>
    display.error("Unexpected Exception, this is probably a bug: %s" % to_text(e), wrap_text=False)
  File "/usr/lib/python2.7/site-packages/ansible_runner/display_callback/display.py", line 41, in wrapper
    return f(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/ansible/utils/display.py", line 287, in error
    self.display(new_msg, color=C.COLOR_ERROR, stderr=True)
  File "/usr/lib/python2.7/site-packages/ansible_runner/display_callback/display.py", line 89, in wrapper
    event_context.dump_begin(fileobj)
  File "/usr/lib/python2.7/site-packages/ansible_runner/display_callback/events.py", line 176, in dump_begin
    self.cache.set(":1:ev-{}".format(begin_dict['uuid']), begin_dict)
  File "/usr/lib/python2.7/site-packages/ansible_runner/display_callback/events.py", line 50, in set
    os.mkdir(os.path.join(self.private_data_dir, 'job_events'))
OSError: [Errno 2] No such file or directory: './demo/artifacts/7f12bc40-b806-4a70-aa39-8d9bc1ae3305/job_events'

ssh_key being malformed in the setup process (python)

When I add a ssh_key in the folder structure, it is malformed when passed through the safe_load function of the pyyaml library.
It goes from something like:
-----BEGIN RSA PRIVATE KEY-----\nThe content\n-----END RSA PRIVATE KEY-----
To something like:
-----BEGIN RSA PRIVATE KEY----- The content -----END RSA PRIVATE KEY-----
Which, in turn, makes the runner fail with:
Error loading key "/tmp/tmpprvw4sg6/artifacts/c79a77f5-a477-4b26-8a11-ee4802b3b589/ssh_key_data": invalid format

I modified loader.py a little to add an extra loader:
image

This "loader" just checks for the beginning of the content, but could be set to something more elaborate that validates the key format:
image

I don't know if this issue is happening to someone else, but without these changes, the python runner won't work for me.

If this is confirmed as an issue, I could create a PR proposing a formal fix. Otherwise, please help me pinpoint what am I doing wrong.

Roles included in a play send three identical runner_on_ok messages to callback

This play:

hosts: localhost
gather_facts: false
roles:
    - hello

Created three copies of this message:

{u'counter': 4,
 u'created': u'2018-08-06T20:02:55.605063',
 u'end_line': 7,
 u'event': u'runner_on_ok',
 u'event_data': {u'event_loop': None,
                 u'host': u'localhost',
                 u'pid': 77031,
                 u'play': u'localhost',
                 u'play_pattern': u'localhost',
                 u'play_uuid': u'9801a79a-dd33-c9e6-7a97-000000000006',
                 u'playbook': u'playbook.yml',
                 u'playbook_uuid': u'44730e6f-e077-4ad0-bd00-a819c7fcaaf8',
                 u'remote_addr': u'localhost',
                 u'res': {u'_ansible_no_log': False,
                          u'_ansible_verbose_always': True,
                          u'changed': False,
                          u'msg': u'Hello world!'},
                 u'role': u'hello',
                 u'task': u'debug',
                 u'task_action': u'debug',
                 u'task_args': u'',
                 u'task_path': u'/Users/bthomass/git/ansible_kernel_prototype/notebooks/roles/hello/tasks/main.yml:2',
                 u'task_uuid': u'9801a79a-dd33-c9e6-7a97-00000000000e'},
 u'pid': 77031,
 u'start_line': 4,
 u'stdout': u'\x1b[0;32mok: [localhost] => {\x1b[0m\r\n\x1b[0;32m    "msg": "Hello world!"\x1b[0m\r\n\x1b[0;32m}\x1b[0m',
 u'uuid': u'b411e04b-1d14-4dde-ab52-c18af7de2326'}

This does not happen for include_role.

Silent fail without <private_data_dir>/project/ directory

I need to have at least blank <private_data_dir>/project/ dir, otherwise the ansible-runner run ... doesn't finish. I couldn't find any failure, it just prints warning about <private_data_dir>/env/... files and then ends. With the empty project dir, it works correctly.

Extravars breaks some values

Having extra vars file

count: '2'
image_uuid: ami-a4dc46db
instance_indexed_tags: |-
  Name: ladas_ansible_test_2
  TestTag: test2
  TestTag2: test2
instance_name: ladas_ansible_test_2
instance_tags: |-
  Name: ladas_ansible_test_2
  TestTag: test2
instance_type: t2.nano
key_pair: ladas_ansible
region: us-east-1
security_group_description: ladas_ansible_test_1_sc_description
security_group_id: ''
security_group_name: ladas_ansible_test_1_sc_name
security_group_rules: |-
  - proto: tcp
    from_port: 22
    to_port: 22
    cidr_ip: 0.0.0.0/0
  - proto: tcp
    from_port: 80
    to_port: 80
    cidr_ip: 0.0.0.0/0
  - proto: tcp
    from_port: 443
    to_port: 443
    cidr_ip: 0.0.0.0/0
security_group_rules_egress: |-
  - proto: all
    cidr_ip: 0.0.0.0/0
vpc_id: vpc-ff49ff91
vpc_subnet_id: subnet-5f5a9670

Ansible runner passes security_group_rules: "-" into my playbook. Similar behavior is if security_group_rules is a nested array.

Expecting this to work like ansible-playbook, where I can pass nested array or multiline string.

Structure in docs does not correspond with functionality

According to https://ansible-runner.readthedocs.io/en/latest/intro.html#runner-input-directory-hierarchy

The roles directory is outside of project folder:
image
When I set up my structure like that, I get:

The role xxx was not found in /tmp/tmp2le4eyz0/project/roles:/home/ubuntu/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/tmp/tmp2le4eyz0/project

Obviously, moving roles to be inside the project folder fixes the issue.
Is this a bug or a documentation error? If the error is in the documentation, let me know and I can make the change.

Allow passing playbooks/roles directly to run()

Currently these playbooks and roles must be present in the private_data_dir and playbook is selected as a filename from their.

By implementing this we could remove the absolute requirement to have the private_data_dir

How to debug?

I am running the demo on this project. Cloned the repo, copied it to /tmp and ran the following commands:

image
Nothing outputs.
r.status is 'failed' but there is no clue about what is failing.

is-alive and stop methods strange behavior

It seems like is-alive gives return code 0 while the job is running and 1 once it's done. Is that the expected behavior?

But stop gives always return code 1, there is no error (even if I use -vvvvv or --debug), and the process keeps running. But after a current play finishes, it seems to stop (output file is blank and rc is missing). Is waiting till the current play finishes? It would be good to fill in the rc at least.

If stop is a graceful exit, could we add also kill method?

KeyError: 'PATH' on ansible-playbook execution

[root@opnfv ansible-runner]# ansible-playbook -i 192.168.121.114, -u ansible -k -e ansible_network_os=junos dan-test.yaml
SSH password:

PLAY [Network Getting Started First Playbook] *********************************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************************************
ok: [192.168.121.114]

TASK [Get config for junos switch] ********************************************************************************************************************************************************************************
ok: [192.168.121.114]

PLAY RECAP ********************************************************************************************************************************************************************************************************
192.168.121.114 : ok=2 changed=0 unreachable=0 failed=0

[root@opnfv ansible-runner]# python dan-test.py
Not loading passwords
Not loading environment vars
Not loading extra vars
Not loading settings
Not loading ssh key
Parsed /tmp/tmpNsTCJY/inventory/hosts.json inventory source with yaml plugin

PLAYBOOK: main.json ************************************************************
1 plays in /tmp/tmpNsTCJY/project/main.json

PLAY [Openstack networking-ansible test] ***************************************

TASK [Gathering Facts] *********************************************************
The full traceback is:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 138, in run
res = self._execute()
File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 516, in _execute
self._connection = self._get_connection(variables=variables, templar=templar)
File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 790, in _get_connection
socket_path = self._start_connection()
File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 877, in _start_connection
[python, find_file_in_path('ansible-connection'), to_text(os.getppid())],
File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 868, in find_file_in_path
paths = os.environ['PATH'].split(os.pathsep) + [os.path.dirname(sys.argv[0])]
File "/usr/lib64/python2.7/UserDict.py", line 23, in getitem
raise KeyError(key)
KeyError: 'PATH'
fatal: [192.168.121.114]: FAILED! => {
"msg": "Unexpected failure during module execution.",
"stdout": ""
}

PLAY RECAP *********************************************************************
192.168.121.114 : ok=0 changed=0 unreachable=0 failed=1

[root@opnfv ansible-runner]# cat dan-test.yaml

  • name: Network Getting Started First Playbook
    connection: netconf
    hosts: all
    tasks:

    • name: Get config for junos switch
      junos_facts:
      [root@opnfv ansible-runner]# cat dan-test.py
      import ansible_runner as ar

pb = [{
'name': 'Openstack networking-ansible test',
'connection': 'netconf',
'hosts': '192.168.121.114',
'tasks': [
{'name': 'Gather Facts',
'junos_facts': None,}
]
}]

inventory = {'all':
{'hosts':
{'192.168.121.114':
{'ansible_user': 'ansible',
'ansible_ssh_pass': 'password'}
}
}
}

ar.run(playbook=pb, inventory=inventory)

No module named psutil

When running the demo python code, I am getting:
image

I am running it using the following environment:
image

As it can be seen in the attached image, I do have psutil. Ansible-runner is updated.

--json param puts invalid JSON on stdout

Looks like there are few stdout prints breaking the --json, e.g. I see:

*** JSON::ParserError Exception: 765: unexpected token at 'Not loading passwords
Not loading settings
Not loading ssh key

But even if I remove those starting lines, it doesn't seem to be a valid json on the output. I see several {} entities not inside of an []?

add command line argument to `ansible-runner` to handle debug

Add a new command line argument to the ansible-runner command to enable verbose logging to a file. File logging was added in #32 but decided to wait until #35 was merged before adding the command line option. Once both PRs are merged, then the argument can easily be added to ansible-runner

Cannot run from python

I am trying to run some playbook. I created the directory structure, provided an ssh key, the playbook (it is in a subfolder of "project") and the inventory.
I am getting the following error:
image

I am running ansible 2.5.1 installed in system (the one I had installed in virtualenv did not work).

Any idea about what I am doing wrong?

Allow providing multiple ssh keys

Currently runner assumes a single private key be provided through the module interface and via env/ssh_key. We should support multiples since behind the scenes we are using ssh-agent.

-q option doesn't work well

When I use the ansible-runner(1.0.5) command with -q option, there will still be output。
The output is as follows:

TASK [config xxx] *****************************************************

TASK [create xxx] ******************************************************

TASK [remove xxx] **********************************************

TASK [unarchive xxx] ************************************************

192.168.6.246 : ok=29 changed=15 unreachable=0 failed=0

When a file is not loaded, a reason should be present

I noticed the following behaviour (test.py just contains the 2 lines in the readme for running from python):
image

The file could fail to load for several reasons. I guess that those are mainly:

  • File does not exist
  • File is not well formatted

With the current message, the user has no idea if the system is not loading it correctly (because there is some issue with the naming convention) or is not able to parse (syntax issue in the image).

Should that be validated to improve the messages?

Doc example isn't working as is.

Hi there,

Maybe I'm missing something, but here are the steps to reproduce :

  • python 3.6.5

  • ansible-runner 1.0.5

  • test.yml :

$ cat test.yml 
---
- hosts: localhost
  tasks:
    - shell: ping -c 1 localhost
  • code :
import ansible_runner
r = ansible_runner.run(private_data_dir='/tmp/demo', playbook='test.yml')
print(r.stats)
  • Gives TypeError :

Traceback (most recent call last):
File "", line 1, in
File "/home/steven/PycharmProjects/ansible-API/venv/lib/python3.6/site-packages/ansible_runner/runner.py", line 245, in stats
last_event = last_event[0]['event_data']
TypeError: 'filter' object is not subscriptable

  • Replacing print(r.stats) with :
for each_host_event in r.events:
     print(each_host_event.event)
  • Throws :

AttributeError: 'dict' object has no attribute 'event'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.