Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible random UUID generation

Tags:

ansible

In my Ansible script, I want to generate UUIDs on the fly and use them later on.

Here is my approach:

- shell: echo uuidgen
  with_sequence: count=5
  register: uuid_list


  - uri: 
      url: http://www.myapi.com
      method: POST
      body: "{{ item.item.stdout }}"
    with_items: uuid_list.result

However I get the following error:

fatal: [localhost] => One or more undefined variables: 'str object' has no attribute 'stdout'

How can I solve this issue?

like image 427
Mudaer Avatar asked May 28 '15 19:05

Mudaer


1 Answers

In ansible 1.9 there is a new filter : to_uuid , which given a string it will return an ansible domain specific UUID,you can find the usage in here https://docs.ansible.com/playbooks_filters.html#other-useful-filters

like image 153
Xingxing Gao Avatar answered Sep 23 '22 20:09

Xingxing Gao