Compare two variables in Ansible [duplicate]
This question already has an answer here:
Ansible: compare variables
1 answer
I am writing a script to change passwords on multiple servers. The script accepts username and password as input.
It should ask for password twice and compare if they are equal.
I could not find a way to compare two variables. Here's what I have at the moment:
vars_prompt:
- name: user_name
prompt: Enter the user name for password reset
private: no
- name: pass
prompt: Enter the password
- name: re-pass
prompt: Re-enter the password
tasks:
- name: Verify Password
debug:
msg: "Equal"
when: pass is match re-pass
ansible
marked as duplicate by nwinkler, Matthew L Daniel, Community♦ Dec 6 '18 at 15:04
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Ansible: compare variables
1 answer
I am writing a script to change passwords on multiple servers. The script accepts username and password as input.
It should ask for password twice and compare if they are equal.
I could not find a way to compare two variables. Here's what I have at the moment:
vars_prompt:
- name: user_name
prompt: Enter the user name for password reset
private: no
- name: pass
prompt: Enter the password
- name: re-pass
prompt: Re-enter the password
tasks:
- name: Verify Password
debug:
msg: "Equal"
when: pass is match re-pass
ansible
marked as duplicate by nwinkler, Matthew L Daniel, Community♦ Dec 6 '18 at 15:04
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Ansible: compare variables
1 answer
I am writing a script to change passwords on multiple servers. The script accepts username and password as input.
It should ask for password twice and compare if they are equal.
I could not find a way to compare two variables. Here's what I have at the moment:
vars_prompt:
- name: user_name
prompt: Enter the user name for password reset
private: no
- name: pass
prompt: Enter the password
- name: re-pass
prompt: Re-enter the password
tasks:
- name: Verify Password
debug:
msg: "Equal"
when: pass is match re-pass
ansible
This question already has an answer here:
Ansible: compare variables
1 answer
I am writing a script to change passwords on multiple servers. The script accepts username and password as input.
It should ask for password twice and compare if they are equal.
I could not find a way to compare two variables. Here's what I have at the moment:
vars_prompt:
- name: user_name
prompt: Enter the user name for password reset
private: no
- name: pass
prompt: Enter the password
- name: re-pass
prompt: Re-enter the password
tasks:
- name: Verify Password
debug:
msg: "Equal"
when: pass is match re-pass
This question already has an answer here:
Ansible: compare variables
1 answer
ansible
ansible
edited Nov 27 '18 at 7:09
nwinkler
33k16108128
33k16108128
asked Nov 26 '18 at 18:41
SubuSubu
31
31
marked as duplicate by nwinkler, Matthew L Daniel, Community♦ Dec 6 '18 at 15:04
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by nwinkler, Matthew L Daniel, Community♦ Dec 6 '18 at 15:04
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Could not find a way to compare two varaibles
The thing you want is assert:
, but you will also want to actually name your variable a python-compatible name, else you will have to use the "dict" syntax to access it all the time, which will become annoying:
vars_prompt:
- name: pass
- name: re_pass
tasks:
- name: ensure passwords are equal
assert:
that:
- pass == re_pass
1
Thanks Matthew. That worked:)
– Subu
Dec 6 '18 at 15:05
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Could not find a way to compare two varaibles
The thing you want is assert:
, but you will also want to actually name your variable a python-compatible name, else you will have to use the "dict" syntax to access it all the time, which will become annoying:
vars_prompt:
- name: pass
- name: re_pass
tasks:
- name: ensure passwords are equal
assert:
that:
- pass == re_pass
1
Thanks Matthew. That worked:)
– Subu
Dec 6 '18 at 15:05
add a comment |
Could not find a way to compare two varaibles
The thing you want is assert:
, but you will also want to actually name your variable a python-compatible name, else you will have to use the "dict" syntax to access it all the time, which will become annoying:
vars_prompt:
- name: pass
- name: re_pass
tasks:
- name: ensure passwords are equal
assert:
that:
- pass == re_pass
1
Thanks Matthew. That worked:)
– Subu
Dec 6 '18 at 15:05
add a comment |
Could not find a way to compare two varaibles
The thing you want is assert:
, but you will also want to actually name your variable a python-compatible name, else you will have to use the "dict" syntax to access it all the time, which will become annoying:
vars_prompt:
- name: pass
- name: re_pass
tasks:
- name: ensure passwords are equal
assert:
that:
- pass == re_pass
Could not find a way to compare two varaibles
The thing you want is assert:
, but you will also want to actually name your variable a python-compatible name, else you will have to use the "dict" syntax to access it all the time, which will become annoying:
vars_prompt:
- name: pass
- name: re_pass
tasks:
- name: ensure passwords are equal
assert:
that:
- pass == re_pass
answered Nov 27 '18 at 7:11
Matthew L DanielMatthew L Daniel
8,90612728
8,90612728
1
Thanks Matthew. That worked:)
– Subu
Dec 6 '18 at 15:05
add a comment |
1
Thanks Matthew. That worked:)
– Subu
Dec 6 '18 at 15:05
1
1
Thanks Matthew. That worked:)
– Subu
Dec 6 '18 at 15:05
Thanks Matthew. That worked:)
– Subu
Dec 6 '18 at 15:05
add a comment |