canonical / canonical/cloud-init

Ansible setup_controller become_password_file issue

Open
#6,166 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
3.8k
Forks
1.1k
Avg merge
3d 8h
Merged PRs (30d)
22

Description

# Bug report
I was testing if I can use become_password_file option in ansible setup_controller but it returns error.

## Steps to reproduce the problem
user-data:
```yaml
#cloud-config
password: password
chpasswd:
expire: False
system_info:
default_user:
name: ubuntu
sudo: ALL=(ALL) ALL
ansible:
install_method: distro
run_user: ubuntu
package_name: ansible-core
setup_controller:
repositories:
- source: "https://github.com/shaerpour/test.git"
path: "/tmp/test/"
run_ansible:
- playbook_name: "play.yml"
playbook_dir: "/tmp/test/"
become_password_file: "pass.txt"
```
playbook:
```yaml
- name: test
hosts: localhost
connection: local
gather_facts: false
become: true
tasks:
- name: test
copy:
content: "test cloud-init"
dest: "/root/test.txt"
```

## Environment details
- Cloud-init version: 25.1.1
- Operating System Distribution: Ubuntu jammy
- Cloud provider, platform or installer type: QEMU

## cloud-init logs
```bash
ubuntu@ubuntu:~$ cloud-init status --long
status: error
extended_status: error - done
boot_status_code: enabled-by-generator
last_update: Thu, 01 Jan 1970 00:00:29 +0000
detail: DataSourceNoCloud [seed=dmi,/dev/sr0][dsmode=local]
errors:
- ('ansible', ProcessExecutionError("Unexpected error while running command.\nCommand: ['su', '-', 'ubuntu', '-c', 'cd /tmp/test/ && env PATH=$PATH ansible-playbook play.yml --become-password-file=pass.txt']\nExit code: 250\nReason: -\nStdout: to see the full traceback, use -vvv\nStderr: ERROR! Unexpected Exception, this is probably a bug: module 'posixpath' has no attribute 'is_executable'"))
recoverable_errors:
DEPRECATED:
- Deprecated cloud-config provided: system_info: Deprecated in version 24.2. System and/or distro specific settings. This is not intended to be overridden by user-data or vendor-data.
- Deprecated cloud-config provided: system_info: Deprecated in version 24.2. System and/or distro specific settings. This is not intended to be overridden by user-data or vendor-data.
- Deprecated cloud-config provided: system_info: Deprecated in version 24.2. System and/or distro specific settings. This is not intended to be overridden by user-data or vendor-data.
- Deprecated cloud-config provided: system_info: Deprecated in version 24.2. System and/or distro specific settings. This is not intended to be overridden by user-data or vendor-data.
WARNING:
- Running module ansible () failed
```
I'm currently working on this issue to see if I can find a solution.

Contributor guide

Open the contributing guide

Research direction

Reproduce the configuration with the provided user-data and playbook, then inspect cloudinit/config/cc_ansible.py and the setup_controller handling around become_password_file. Compare the generated ansible-playbook command with the reported traceback. Done means the setup_controller run completes successfully and creates /root/test.txt without the posixpath error.

Written by the indexing model from the issue text.

Assessment

Tech stack
ansible, python
Domain
cloud, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.