Hi All,
I am facing an issue with the JSON query to get value to one variable . Code and Ansible output is given below . Response of JSON is coming as null .
-
name: print user and password
debug:
msg: “Start_result= {{ ssm_parameter }}” -
name: save the Json data to a Variable as a Fact
set_fact:
jsondata: “{{ ssm_parameter.stdout | from_json }}” -
name: setDomainName
set_fact:
DPM_password: “{{ jsondata | json_query(?key==‘SecretString.SB_password’) }}”
vars:
#jmesquery: “[jsondata.SecretString]”
#query: “[?key==‘{{ project_environment }}’].value.current” -
name: print user and password
debug:
msg: “Start_result= {{ jsondata | json_query(‘SecretString.SB__password’) }}”
SK [ssmpassword : save the Json data to a Variable as a Fact] ****************
task path: /opt/jenkins/workspace/PROJECTS/hello/General/SSMpassword/ansible/playbooks/roles/ssmpassword/tasks/main.yml:12
ok: [[xxxx.abc.com](http://xxxx.abc.com)] => {"ansible_facts": {"jsondata": {"ARN": "arn:aws:secretsmanager:us-west-1:1234:secret:Test_Hello-sgoCgf", "CreatedDate": 1612884866.834, "Name": "Test_Hello", "SecretString": "{\"SB__password\":\"Hello123!1\"}", "VersionId": "ad811140-b5d6-461b-9838-37a750bf8209", "VersionStages": ["AWSCURRENT"]}}, "changed": false}
TASK [ssmpassword : setDomainName] *********************************************
task path: /opt/jenkins/workspace/PROJECTS/hello/General/SSMpassword/ansible/playbooks/roles/ssmpassword/tasks/main.yml:16
ok: [[xxxx.abc.com](http://xxxx.abc.com)] => {"ansible_facts": {"SB_password": ""}, "changed": false}
TASK [ssmpassword : print user and password] ***********************************
task path: /opt/jenkins/workspace/PROJECTS/hello/General/SSMpassword/ansible/playbooks/roles/ssmpassword/tasks/main.yml:24
ok: [[xxxx.abc.com](http://xxxx.abc.com)] => {
"msg": "Start_result= "
Pleae guide me it is urgent .
Regards,
Deepak