Looking for generic execute "once-only" practise for Automations

13 views
Skip to first unread message

Timothy Dilbert

unread,
May 10, 2022, 4:47:28 PM5/10/22
to Ansible Development
Hi Guys,

We use Ansible to perform a number of integrations with third-party systems. 
e.g.
  1. Sync this user's information from System X to System Y.
  2. If the user is a member of AD group "LicenseManagement", send an email to Person Z.
  3. etc.
In most of our integrations we need to execute the action only once per user. There are a growing number of integrations where we can't connect to their platform, and so I need a native way within Ansible to track whether the automation has already been actioned (for the subject user). 

I am putting this out here to see if anyone has come across this before. And if there are any native things we can do within Red Hat Ansible Tower to track these sorts of states.

Brian Coca

unread,
May 11, 2022, 1:33:57 PM5/11/22
to Timothy Dilbert, Ansible Development
Many ways, just an example:
- in a handler update a host_vars/<sytemY>.yml with the list of users
already synced, notify when sync tasks run/change
- add to sync role/block/tasks a conditional based on the variable
cdreated `when: username not in already_processed_users`



--
----------
Brian Coca

Timothy A. Dilbert | BMT

unread,
May 11, 2022, 1:45:48 PM5/11/22
to Brian Coca, Ansible Development
Hey Brian,

I like the idea of using host_vars

Within the playbook I will need to update host_vars based on the outcome of the job. For example, after emailing user jdoe​, update variable emailed_users​. That way, when the job runs again a few minutes later, I want the second job to know what work was completed on the first job so not to email jdoe​ again. Hopefully that example makes sense.

Is there a way within the playbook that I can add jdoe​ to emailed_users​​, and record that change so that the variable change persists across multipe Ansible Tower jobs?

Timothy Dilbert



From: Brian Coca <bc...@redhat.com>
Sent: 11 May 2022 12:33
To: Timothy A. Dilbert | BMT <Timothy...@bmt.ky>
Cc: Ansible Development <ansibl...@googlegroups.com>
Subject: Re: [ansible-devel] Looking for generic execute "once-only" practise for Automations
 
Reply all
Reply to author
Forward
0 new messages