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 > <https://groups.google.com/d/msgid/ansible-project/e629b83c-3a43-4510-8213-948fc5b7d3c9%40googlegroups.com?utm_medium=email&utm_source=footer> > . > 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/CAFUV_d5KXA9w2Gu0KD%3DJ3HtfMt38jGOb9OjhQSZjSq-HeMK4Cw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
