Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for recording Ansible adhoc commands #27

Open
dmsimard opened this issue Apr 24, 2019 · 1 comment
Open

Add support for recording Ansible adhoc commands #27

dmsimard opened this issue Apr 24, 2019 · 1 comment
Labels

Comments

@dmsimard
Copy link
Contributor

@dmsimard dmsimard commented Apr 24, 2019

ansible-playbook commands have always been recorded by ara if the callback plugin was loaded.

By default, callback plugins are not enabled for ansible adhoc commands but they can be enabled by setting bin_ansible_callbacks in ansible.cfg or the ANSIBLE_LOAD_CALLBACK_PLUGINS env variable to True.

However, enabling this at time of writing does not work because there is no v2_playbook_on_start callback hook fired, it goes straight to v2_play_on_start so we have no playbook to tie the data back into:

$ ansible localhost -m setup -vvv
# [...]

 [WARNING]: Failure using method (v2_playbook_on_play_start) in callback plugin (<ansible.plugins.callback./home/fedora/.ara/virtualenv/lib/python3.7/site-packages/ara/plugins/callback/ara_default.CallbackModule object at 0x7f3d283eb0f0>): 'NoneType'
object is not subscriptable

Callback Exception: 
  File "/home/fedora/.ara/virtualenv/lib64/python3.7/site-packages/ansible/executor/task_queue_manager.py", line 375, in send_callback
    method(*new_args, **kwargs)
   File "/home/fedora/.ara/virtualenv/lib/python3.7/site-packages/ara/plugins/callback/ara_default.py", line 173, in v2_playbook_on_play_start
    "/api/v1/plays", name=play.name, status="running", uuid=play._uuid, playbook=self.playbook["id"]

META: ran handlers
 [WARNING]: Failure using method (v2_playbook_on_task_start) in callback plugin (<ansible.plugins.callback./home/fedora/.ara/virtualenv/lib/python3.7/site-packages/ara/plugins/callback/ara_default.CallbackModule object at 0x7f3d283eb0f0>): 'NoneType'
object is not subscriptable

Callback Exception: 
  File "/home/fedora/.ara/virtualenv/lib64/python3.7/site-packages/ansible/executor/task_queue_manager.py", line 375, in send_callback
    method(*new_args, **kwargs)
   File "/home/fedora/.ara/virtualenv/lib/python3.7/site-packages/ara/plugins/callback/ara_default.py", line 194, in v2_playbook_on_task_start
    path = self.playbook["path"]

# [...]
localhost | SUCCESS => {
    "ansible_facts": {
        "ansible_all_ipv4_addresses": [
            "10.88.0.1",
            "172.24.0.11"
        ],
       # [...]
        "gather_subset": [
            "all"
        ],
        "module_setup": true
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "fact_path": "/etc/ansible/facts.d",
            "filter": "*",
            "gather_subset": [
                "all"
            ],
            "gather_timeout": 10
        }
    }
}
 [WARNING]: Failure using method (v2_runner_on_ok) in callback plugin (<ansible.plugins.callback./home/fedora/.ara/virtualenv/lib/python3.7/site-packages/ara/plugins/callback/ara_default.CallbackModule object at 0x7f3d283eb0f0>): 'NoneType' object is not
subscriptable

Callback Exception: 
  File "/home/fedora/.ara/virtualenv/lib64/python3.7/site-packages/ansible/executor/task_queue_manager.py", line 375, in send_callback
    method(*new_args, **kwargs)
   File "/home/fedora/.ara/virtualenv/lib/python3.7/site-packages/ara/plugins/callback/ara_default.py", line 216, in v2_runner_on_ok
    self._load_result(result, "ok", **kwargs)
   File "/home/fedora/.ara/virtualenv/lib/python3.7/site-packages/ara/plugins/callback/ara_default.py", line 288, in _load_result
    host = self._get_or_create_host(result._host.get_name())
   File "/home/fedora/.ara/virtualenv/lib/python3.7/site-packages/ara/plugins/callback/ara_default.py", line 280, in _get_or_create_host
    return self.client.post("/api/v1/hosts", name=host, alias=host_alias, playbook=self.playbook["id"])

META: ran handlers
META: ran handlers
 [WARNING]: Failure using method (v2_playbook_on_stats) in callback plugin (<ansible.plugins.callback./home/fedora/.ara/virtualenv/lib/python3.7/site-packages/ara/plugins/callback/ara_default.CallbackModule object at 0x7f3d283eb0f0>): 'NoneType' object
is not subscriptable

Callback Exception: 
  File "/home/fedora/.ara/virtualenv/lib64/python3.7/site-packages/ansible/executor/task_queue_manager.py", line 375, in send_callback
    method(*new_args, **kwargs)
   File "/home/fedora/.ara/virtualenv/lib/python3.7/site-packages/ara/plugins/callback/ara_default.py", line 231, in v2_playbook_on_stats
    self._load_stats(stats)
   File "/home/fedora/.ara/virtualenv/lib/python3.7/site-packages/ara/plugins/callback/ara_default.py", line 335, in _load_stats
    host = self._get_or_create_host(hostname)
   File "/home/fedora/.ara/virtualenv/lib/python3.7/site-packages/ara/plugins/callback/ara_default.py", line 280, in _get_or_create_host
    return self.client.post("/api/v1/hosts", name=host, alias=host_alias, playbook=self.playbook["id"])

We need to investigate what's the best course of action to support this.
For example, if there is no playbook, should v2_play_on_start create a "fake" one ?

@dmsimard

This comment has been minimized.

Copy link
Contributor Author

@dmsimard dmsimard commented Apr 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.