ansible-collections / ansible-collections/google.cloud

getting `sudo: a password is required` error on `gcp_sql_instance_info` when using `delegate_to: "localhost" `

Open
#490 1 comment 0 reactions 0 assignees View on GitHub
stale
Dominant language
Python
Stars
105
Forks
144
Avg merge
5d 10h
Merged PRs (30d)
4

Description

##### SUMMARY

getting `sudo: a password is required` error on `gcp_sql_instance_info` when using `delegate_to: "localhost" `
##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME

google.cloud.gcp_sql_instance_info

##### ANSIBLE VERSION

```paste below
ansible-playbook 2.10.15
config file = /Users/ha85006/gitrepos/ansible-playbooks/ansible-role-wordpress/tests/ansible.cfg
configured module search path = ['/Users/ha85006/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /Users/ha85006/Library/Python/3.9/lib/python/site-packages/ansible
executable location = /Users/ha85006/Library/Python/3.9/bin/ansible-playbook
python version = 3.9.4 (default, Apr 5 2021, 01:49:30) [Clang 12.0.0 (clang-1200.0.32.29)]
```

##### COLLECTION VERSION

```paste below
1.0.2
```

##### CONFIGURATION

```paste below
ha85006$ ansible-config dump --only-changed
DEFAULT_HOST_LIST(/Users/ha85006/gitrepos/ansible-playbooks/ansible-role-wordpress/tests/ansible.cfg) = ['/Users/ha85006/gitrepos/ansible-playbooks/ansible-role-wordpress
DEFAULT_ROLES_PATH(/Users/ha85006/gitrepos/ansible-playbooks/ansible-role-wordpress/tests/ansible.cfg) = ['/Users/ha85006/gitrepos/ansible-playbooks']
DEFAULT_STDOUT_CALLBACK(/Users/ha85006/gitrepos/ansible-playbooks/ansible-role-wordpress/tests/ansible.cfg) = yaml
HOST_KEY_CHECKING(env: ANSIBLE_HOST_KEY_CHECKING) = False
INTERPRETER_PYTHON(/Users/ha85006/gitrepos/ansible-playbooks/ansible-role-wordpress/tests/ansible.cfg) = /usr/local/bin/python3
```

##### OS / ENVIRONMENT

macOS BigSur 11.6.5

##### STEPS TO REPRODUCE

run a simple playbook with the following command

```yaml
- name: main | get info on the db instances
google.cloud.gcp_sql_instance_info:
project: '{{ gcp_project_id }}'
register: mysql_instances
delegate_to: "localhost"
run_once: yes
```

##### EXPECTED RESULTS

it should return vm details

##### ACTUAL RESULTS

```paste below
ha85006$ . doit.sh
Activated service account credentials for: [ansible-playbook-svc-act-dv@wd3-XXXX.iam.gserviceaccount.com]

PLAY [Create wordpress site] *********************************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************************************
ok: [35.XXX.XXX.189]

TASK [ansible-role-wordpress : main | get info on the db instances] ******************************************************************************************************
fatal: [35.XXX.XXX.189 -> localhost]: FAILED! => changed=false
module_stderr: |-
sudo: a password is required
module_stdout: ''
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
rc: 1

NO MORE HOSTS LEFT *******************************************************************************************************************************************************

PLAY RECAP ***************************************************************************************************************************************************************
35.XXX.XXX.189 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with the google.cloud.gcp_sql_instance_info task and its delegate_to: localhost playbook. Investigate the module entry point and how delegated execution invokes sudo, then verify the task returns the GCP SQL instance details without the password-required error.

Written by the indexing model from the issue text.

Assessment

Tech stack
google-cloud, python
Domain
cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.