Hello All,
I am trying to pass a file (VAULT-PASS.YML) using Ansible built in module vars and taking input from user and then comparing it using assert module , If the input matches with the content given in file vault-pass.yml then it will prompt success message and execute application deployment and service file which will run in a pod in Kubernetes.
- name: Execute Task
hosts: localhost
become: true
tasks:
- name: Load Secrets
ansible.builtin.include_vars:
file: /home/xyz/vault-pass.yml
- name: Prompt for Credentials
vars_prompt:
- name: entered_username
prompt: "Enter the username"
private: no
- name: entered_password
prompt: "Enter the password"
private: yes
- name: Verify Credentials
assert:
that:
- entered_username == "secret_username"
- entered_password == "secret_password"
fail_msg: "Invalid credentials. Deployment aborted."
success_msg: "Valid credentials. Proceeding with deployment."
- name: Include Kubernetes Deployment
include_tasks: basicapp-deployment.yml
when: entered_username == secret_username and entered_password == secret_password
- name: Include Kubernetes Service
include_tasks: basic-service.yml
when: entered_username == secret_username and entered_password == secret_password
Getting below error
ERROR! unexpected parameter type in action: <class ‘ansible.parsing.yaml.objects.AnsibleSequence’>
The error appears to be in ‘/home/jatin/execute.yml’: line 5, column 5, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:
- name: Prompt for Credentials
^ here
Below is my vault-pass.yml file content
secret_username:abcd
secret_password:Welcome@12345