Skip to content

fix(cc_ansible): pip install_method not working if run_user set#6172

Closed
shaerpour wants to merge 1 commit into
canonical:mainfrom
shaerpour:ansible-pip-run-user-issue
Closed

fix(cc_ansible): pip install_method not working if run_user set#6172
shaerpour wants to merge 1 commit into
canonical:mainfrom
shaerpour:ansible-pip-run-user-issue

Conversation

@shaerpour
Copy link
Copy Markdown
Contributor

because not running python commands inside single quotes

  • I have signed the CLA: https://ubuntu.com/legal/contributors
  • I have included a comprehensive commit message using the guide below
  • I have added unit tests to cover the new behavior under tests/unittests/
    • Test files should map to source files i.e. a source file cloudinit/example.py should be tested by tests/unittests/test_example.py
    • Run unit tests with tox -e py3
  • I have kept the change small, avoiding unnecessary whitespace or non-functional changes.
  • I have added a reference to issues that this PR relates to in the PR message (Refs integration: do not LXD bind mount /etc/cloud/cloud.cfg.d #1234, Fixes integration: do not LXD bind mount /etc/cloud/cloud.cfg.d #1234)
  • I have updated the documentation with the changed behavior.
    • If the change doesn't change the user interface and is trivial, this step may be skipped.
    • Cloud-config documentation is generated from the jsonschema.
    • Generate docs with tox -e docs.

Proposed Commit Message

fix(cc_ansible): pip install_method not working if run_user set
because not running python commands inside single quotes

Additional Context

Test Steps

As mentioned in #6171 running below cloud-init config file will raise an error because bash syntax error because python's commands are parsing as they are not in single quotes.

#cloud-config
password: password
chpasswd:
  expire: False
ansible:
  install_method: pip
  run_user: ubuntu
  package_name: ansible-core
  pull:
    url: https://github.com/shaerpour/test.git
    playbook_name: play.yml

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

Fixes #6171

@shaerpour shaerpour force-pushed the ansible-pip-run-user-issue branch from 7110d9d to 724a2a8 Compare April 19, 2025 07:55
because not running python commands inside single quotes
@shaerpour shaerpour force-pushed the ansible-pip-run-user-issue branch from 724a2a8 to a3d5201 Compare April 27, 2025 11:47
@TheRealFalcon
Copy link
Copy Markdown
Contributor

Thanks for raising this issue!

I think we have a deeper issue here though. The string you're modifying is passed to the do_as() function, which is supposed to be a wrapper over subp(), but the double quoting won't work with supb(), and the argument to do_as() should ideally be compatible with both .

I'm wondering if it'd be possible to modify the base of do_as() to not require the double quoting.

@shaerpour
Copy link
Copy Markdown
Contributor Author

Dear @TheRealFalcon
Sorry for late response, I saw your comment right now.
I'll check how we can support both in do_as() function and update PR.

@github-actions
Copy link
Copy Markdown

Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close.

If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging TheRealFalcon, and he will ensure that someone takes a look soon.

(If the pull request is closed and you would like to continue working on it, please do tag TheRealFalcon to reopen it.)

@github-actions github-actions Bot added the stale-pr Pull request is stale; will be auto-closed soon label May 25, 2025
@shaerpour
Copy link
Copy Markdown
Contributor Author

Comment for not closing PR.

@github-actions github-actions Bot removed the stale-pr Pull request is stale; will be auto-closed soon label Jun 1, 2025
@github-actions
Copy link
Copy Markdown

Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close.

If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging TheRealFalcon, and he will ensure that someone takes a look soon.

(If the pull request is closed and you would like to continue working on it, please do tag TheRealFalcon to reopen it.)

@github-actions github-actions Bot added the stale-pr Pull request is stale; will be auto-closed soon label Jun 16, 2025
@github-actions github-actions Bot closed this Jun 23, 2025
@shaerpour shaerpour deleted the ansible-pip-run-user-issue branch July 8, 2025 07:41
@shaerpour shaerpour restored the ansible-pip-run-user-issue branch August 18, 2025 10:57
@shaerpour shaerpour deleted the ansible-pip-run-user-issue branch August 18, 2025 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale-pr Pull request is stale; will be auto-closed soon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ansible: pip install_method not working if run_user is set

2 participants