Create action plugin script with two modules

Hi Team,

Need some help to develop an action plugin script using two modules. Below is my ansible playbook code:

  • name: Ensure packages are installed yum: name: - xorg-x11-server* - dhcp - bind - vsftpd - dovecot - samba - squid - net-snmp - ypserv - ypbind - rsh - telnet-server - telnet state: absent async: 86400 #24 hours poll: 0 register: yum_installer - name: Waiting for yum package installation to complete
    async_status: jid={{ yum_installer.ansible_job_id }}
    shell: nohup python /opt/ibm/si/saas/ansible/test_neha.py register: console_job_results until: console_job_results.finished retries: 100

Here above in the second task, I am calling two ansible modules at once (shell & async_status) which is giving me the error ERROR! conflicting action statements: shell, async_status, so as an alternative I am now trying to develop an action plugin, which can call two ansible modules at once. Now here, async_status module will go on iteration till the job finished, so on each iteration, I want to call the python script. Thats why going with the approach of developing action plugin.
Need some help regarding the same

Thanks & Regards
Neha Singh

This is one of those answers I dislike the most. Generalized, it goes:

Q. I want to do X but I don’t know how.
A. Want something else.

There are so many levels here it’s hard to know where to start. But the first thing that pops out is that you’ve got “state: absent” on your first task, so you’re just removing some packages. That will not take long, and if it does, waiting longer isn’t going to help. In the case that your “state: absent” is just a copy/paste error (like, you were resetting to “initial conditions” to try your technique again and inadvertently copied that into your question), then perhaps you’re waiting on some other process to get the host into a state where the packages can be installed. If so, I’d suggest you focus on managing that process rather than using the yum task to act as a proxy for it.

Next, there are lots of tricky interactions to consider in creating “strategies” — Ansible’s term for the different ways to batch, group, schedule, and generally manage the running of tasks on various hosts. While lots of modules have associated action plugins, I seriously doubt it would be worth the effort - if it’s even possible - to implement a multi-module action plugin and integrate it cleanly into Ansible’s architecture. Rather, this feels to me a better fit for workflows in AWX/Tower or maybe ansible-runner which I believe is the bit from AWX that handles job scheduling/workflows, but I’ve not gone there before. At any rate, if I were trying to do what you’re thinking about, that’s the direction I’d go in.

Which brings us to the questions I probably should have started with: (a) What is the problem you’re actually trying to solve, and (b) what is unique about your situation that makes the envisioned solution the way to go when nobody else has implemented this already?