you can use sequence, start at 0 and end at list length On Thu, Jun 11, 2015 at 6:36 AM, JohnP <[email protected]> wrote: > I think my question is more "fundamental" as > > How can I capture and use the array member number of with_dict in > results[0].stat.exists like on any primitive language as an example below. > > > #!/bin/bash > for i in 1 2 3 4 5 > do > echo "Welcome $i times" > done > > > > Sample outputs: > > Welcome 1 times > Welcome 2 times > Welcome 3 times > Welcome 4 times > Welcome 5 times > > > Best Regards: JP > > > On Thursday, June 11, 2015 at 11:26:40 AM UTC+1, benno joy wrote: >> >> Hi, >> >> i think this can be solved if you can make you ssl_certs a list of dicts >> and use with_indexed_list >> http://docs.ansible.com/playbooks_loops.html#id22 >> >> >> >> >> On Thu, Jun 11, 2015 at 3:39 PM, JohnP <[email protected]> wrote: >>> >>> Hi Group, >>> >>> I am trying to establish a logic on a creating web server self signed >>> certificates. >>> (please note that this issue could be related any other task like >>> depending on files >>> in directories, etc.) >>> >>> Logic is that I would like to create subsequent files (as cert request >>> and the newly signed key >>> this instance). >>> >>> I am doing stat on the private key earlier in the role. If the private >>> key does NOT >>> exists, I am going to create csr and eventually signed pem file. >>> >>> Please note that my entire logic worked when I did one vhost in a time, >>> perfect. >>> However, when I wanted to do them in a "loop" which more professional and >>> tidy, it hit >>> brick wall since with_dict alters to stat results explained in >>> documentation (hint, hint) >>> After a bit of debugging I have managed to locate location of stat >>> values, but now >>> I am stuck on >>> when: server_private_key.results[0].stat.exists == false >>> issue. How can I match the item number dynamically on results[0] rather >>> than hard coding it to zero? >>> (as can easily be done on any primitive programming language) >>> >>> Best Regards: JP >>> >>> - stat: path={{item.value.ssl_dir}}/{{item.value.ssl_name}}.key >>> register: "server_private_key" >>> with_dict: "{{ssl_certs}}" >>> >>> ---snip--- >>> >>> - name: SSL 'generate-cert-request' >>> shell: "/usr/bin/openssl req -new -subj \"{{item.value.subject}}\" -key >>> {{item.value.ssl_dir}}/{{item.value.ssl_name}}.key -out >>> {{item.value.ssl_dir}}/{{item.value.ssl_name}}.csr" >>> when: server_private_key.results[0].stat.exists == false >>> with_dict: "{{ssl_certs}}" >>> tags: ['generate-server-key-Step-2'] >>> >>> >>> -- >>> 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 post to this group, send email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/ansible-project/e629b83c-3a43-4510-8213-948fc5b7d3c9%40googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >> >> > -- > 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 post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/1d12c4b8-3a52-4cbc-8e7a-b44a5e95e834%40googlegroups.com. > > For more options, visit https://groups.google.com/d/optout.
-- Brian Coca -- 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 post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJ5XC8kPb7DdgzGuP9k1rVJJAtOjTg4xVg_f%2B90%3DtJg%2BcD0eww%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
