---
- name: Ensure packages are installed and display custom message
hosts: your_target_hosts
tasks:
- name: Ensure packages are installed
yum:
name:
- xorg-x11-server*
- dhcp
- bind
- vsftpd
- dovecot
state: present
async: 86400
poll: 0
register: yum_installer
- name: Display custom message using a handler
debug:
msg: "Custom message from Python script: {{ console_job_results.msg
}}"
when: yum_installer.status == 'running'
async_status: jid={{ yum_installer.ansible_job_id }}
register: console_job_results
retries: 100
delay: 10
handlers:
- name: Display custom message when yum installation is complete
debug:
msg: "Custom message from Python script: {{ console_job_results.msg
}}"
when: yum_installer.status == 'successful'
On Tuesday, February 21, 2023 at 12:29:50 AM UTC-8 Neha Singh wrote:
> Hi Team,
>
> Below are the two tasks which I am including in playbook. Main agenda is
> that, when my packages are installing, at that time rather than just
> getting waiting or retried message, I wanted some customised message to
> print as well. That xustomized message, I am retrieving from python script
> (in 2nd task)
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *- name: Ensure packages are installed yum: name: -
> xorg-x11-server* - dhcp - bind - vsftpd - dovecot
> state: present 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: python
> /opt/ibm/si/saas/ansible/test_neha.py register: console_job_results
> until: console_job_results.finished retries: 100 delay: 10*
>
> But I am getting the error *ERROR! conflicting action statements: shell,
> async_status *here. Can you please suggest something, what should be the
> next thing to do here. I really need some customised message to print,
> which I am retrieving from python script. Is there any way to include both
> async_status & python script module in one task.
>
> Thanks
> Neha Singh
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/15d7a21c-ead8-4842-886d-61b25ad8bc1fn%40googlegroups.com.