theforeman / foreman-ansible-modules

Ansible modules for interacting with the Foreman API and various plugin APIs such as Katello
GNU General Public License v3.0
147 stars 163 forks source link

Add support for foreman tasks #807

Open amasolov opened 4 years ago

amasolov commented 4 years ago
SUMMARY

Would be good to have a way to search for running/completed/errored foreman tasks. Searching for state, result, action and being able to count results should give enough functionality to perform maintenance tasks on Satellite for example.

Use cases:

ISSUE TYPE
mdellweg commented 4 years ago

I know, the usability is subject to improvement (we might eventually move to one _facts/_info module per entity), but for now we have a generic foreman_search_facts, that should be able to perform in your use cases.

amasolov commented 4 years ago

@mdellweg thank you for you reply but I couldn't make it work. Always getting the error below despite my attempts to put ID into params. I also think it might be useful to put an example of this into the docs since even searching for foreman tasks is kinda obscure in foreman_search_facts.

fatal: [localhost]: FAILED! => changed=false
  msg: 'Failed to list resource: "missing param ''id'' in parameters"'
  - name: "Search for foreman tasks"
    foreman_search_facts:
      username: "admin"
      password: "password"
      server_url: "https:/foreman.example.com"
      validate_certs: false
      full_details: true
      search: state = running
      resource: tasks
      params:
        id: a3477667-b2c4-4913-be70-b9d3ee746569
    register: result

  - debug:
      var: item.name
    with_items: "{{ result.resources }}"
mdellweg commented 4 years ago

I think, the resource you are looking for is called foreman_tasks.

And you asked just at the right day for: "This is not the resource you are looking for." wave hand

evgeni commented 4 years ago

triage notes: assigning to Matthias for finding a quickfix solution using search facts, long term we should have an own module for that.

amasolov commented 4 years ago

@mdellweg Thanks, using foreman_tasks does the job. Definitely not the most obvious way to search for tasks.