When I try to use AWS CLI command in ansible playbook, getting error
even added the AWS account access key id, secret key and session token but no use.
Script:
-
name: Change DBSNMP User Password in Oracle database and OMS
hosts: dbhosts
become: true
become_user: oracle
vars_files:- dbsnmp_oms_vault_sm.yml
tasks:
-
name: Execute old password from AWS CLI command
script: my_awscli_cmd.sh
register: old_pwd_aws_output -
name: Display old password
debug:
msg: “{{ old_pwd_aws_output.stdout_lines }}”
Error:
fatal: [172.29.4.81]: FAILED! => {“changed”: true, “cmd”: “/usr/local/bin/aws secretsmanager get-secret-value --secret-id oracle_dbsnmp_user_pwd --query ‘SecretString’ --output text”, “delta”: “0:00:00.004354”, “end”: “2025-03-12 08:25:54.128242”, “msg”: “non-zero return code”, “rc”: 127, “start”: “2025-03-12 08:25:54.123888”, “stderr”: “/bin/sh: /usr/local/bin/aws: No such file or directory”, “stderr_lines”: [“/bin/sh: /usr/local/bin/aws: No such file or directory”], “stdout”: “”, “stdout_lines”: }