So This code here should only run if {{ passphrase_length.results[0].stdout }}
is != "0"
However it seems to ignore the comparison.
I have even tried:
when: passphrase_length.results[0].stdout|int != 0
No matter what I do it does not seem to behave as expected.
I have reached the point of desperation as this should work as coded, is there
any strange trick required?
- name: Create empty Passphrase file
file: path="{{ ssl_client_dir }}/{{ item.first_name }}_{{ item.surname
}}.password" state=touch owner=root group=root mode=0755
with_items: ssl_user_clients
- name: check passphrase
shell: "cat {{ ssl_client_dir }}/{{ item.first_name }}_{{ item.surname
}}.password | grep '^[0-9a-zA-Z!@$%^&*()_?~+-=/\\].*' | wc -c"
with_items: ssl_user_clients
register: passphrase_length
ignore_errors: yes
- debug: msg="{{ passphrase_length.results[0].stdout }}"
- debug: var=passphrase_length
- name: Email Passphrase
action: mail host=localhost port=25 subject="trial password" body="your
password is {{ generated_passphrase.stdout }}" from="[email protected]" to={{
item.email }} headers=Reply-To="[email protected]"|X-Special="Something or
other" charset=utf8
with_items: ssl_user_clients
register: pass_emailed
when: passphrase_length.results[0].stdout != "0"
- name: Email Certificate
action: mail host=localhost port=25 subject="Welcome to the Trial" body="{{
email_body }}" from="[email protected]" to={{ item.email }} attach="{{
ssl_client_dir }}/{{ item.first_name }}_{{ item.surname }}.p12 {{ ssl_certs_dir
}}/ca.crt" headers=Reply-To="[email protected]"|X-Special="Something or other"
charset=utf8
with_items: ssl_user_clients
register: cert_emailed
when: passphrase_length.results[0].stdout != "0"
- name: Write password out
lineinfile: dest="{{ ssl_client_dir }}/{{ item.first_name }}_{{ item.surname
}}.password" state=present line="{{ generated_passphrase.stdout }}"
with_items: ssl_user_clients
when: passphrase_length.results[0].stdout != "0"
The log of the run:
TASK: [clientcert | Create empty Passphrase file] *****************************
changed: [10.76.71.194] => (item={'org_name': 'Acme Limited', 'first_name':
'road', 'surname': 'runner', 'locality': 'desert', 'country': 'Cartoonland',
'state': 'neverneverland', 'email': '[email protected]'})
TASK: [clientcert | check passphrase] *****************************************
changed: [10.76.71.194] => (item={'org_name': 'Acme Limited', 'first_name':
'road', 'surname': 'runner', 'locality': 'desert', 'country': 'Cartoonland',
'state': 'neverneverland', 'email': '[email protected]'})
TASK: [clientcert | debug msg="{{ passphrase_length.results[0].stdout }}"] ****
ok: [10.76.71.194] => {
"msg": "51"
}
TASK: [clientcert | debug var=passphrase_length] ******************************
ok: [10.76.71.194] => {
"var": {
"passphrase_length": {
"changed": true,
"msg": "All items completed",
"results": [
{
"changed": true,
"cmd": "cat /etc/ssl/acme/clients/road_runner.password |
grep '^[0-9a-zA-Z!@$%^&*()_?~+-=/\\].*' | wc -c",
"delta": "0:00:00.011639",
"end": "2015-04-29 10:04:39.908388",
"invocation": {
"module_args": "cat
/etc/ssl/acme/clients/road_runner.password | grep
'^[0-9a-zA-Z!@$%^&*()_?~+-=/\\].*' | wc -c",
"module_name": "shell"
},
"item": {
"country": "Cartoonland",
"email": "[email protected]",
"first_name": "road",
"locality": "desert",
"org_name": "Acme Limited",
"state": "neverneverland",
"surname": "runner"
},
"rc": 0,
"start": "2015-04-29 10:04:39.896749",
"stderr": "",
"stdout": "51",
"stdout_lines": [
"51"
],
"warnings": []
}
]
}
}
}
TASK: [clientcert | Email Passphrase] *****************************************
ok: [10.76.71.194] => (item={'org_name': 'Acme Limited', 'first_name': 'road',
'surname': 'runner', 'locality': 'desert', 'country': 'Cartoonland', 'state':
'neverneverland', 'email': '[email protected]'})
TASK: [clientcert | Email Certificate] ****************************************
ok: [10.76.71.194] => (item={'org_name': 'Acme Limited', 'first_name': 'road',
'surname': 'runner', 'locality': 'desert', 'country': 'Cartoonland', 'state':
'neverneverland', 'email': '[email protected]'})
TASK: [clientcert | Write password out] ***************************************
changed: [10.76.71.194] => (item={'org_name': 'Acme Limited', 'first_name':
'road', 'surname': 'runner', 'locality': 'desert', 'country': 'Cartoonland',
'state': 'neverneverland', 'email': '[email protected]'})
--
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/ef1be346-ad7d-40a9-8823-31c7755ef45c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.