samedi 14 mai 2016

Ansible: Generate a random string and share it between all hosts

I want a task that will generate a random string or timestamp and send that to all hosts in the play.

For example, if I do this:

  • name: Create a unique ID shell: random_string register: unique_id

  • name: store the unique ID lineinfile: dest: '/home/project/config.txt' regexp: 'unique_id' line: 'unique_id = "'

This will generate the random string separately on each remote machine, so they won't match. I could generate it on the local machine using local_action, but it still would run separately for each host. So how can I ensure it will be the same for all hosts?




Aucun commentaire:

Enregistrer un commentaire