Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aptly commands break in wrong directory #62

Open
baurmatt opened this issue Oct 22, 2018 · 1 comment
Open

aptly commands break in wrong directory #62

baurmatt opened this issue Oct 22, 2018 · 1 comment

Comments

@baurmatt
Copy link

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: All
  • Ruby: All
  • Distribution: All
  • Module version: Current master (probably olders as well)

How to reproduce (e.g Puppet code you use)

Run puppet apply -e "aptly::repo { 'testing': }" in /root.

What are you seeing

Puppet tries to recreate the Aptly repository on each run. This is done because aptly -raw=true repo list tries to auto detect the configuration file and this breaks due to insufficient read privileges to /root/.aptly.conf.

https://github.com/aptly-dev/aptly/blob/a64807efdaf5e380bfa878c71bc88eae10d62be1/context/context.go#L92

The reason for is because Puppet switches the UID/GID for this command to 450 (aptly) which obviously has no permission to read /root.

root@stage-packages-api:~# cat test.rb
#!/opt/puppetlabs/puppet/bin/ruby

require 'puppet'

puts Puppet::Util::Execution.execute('aptly -raw=true repo list', uid: 450, gid: 450)
root@stage-packages-api:~# ./test.rb

root@stage-packages-api:~#

What behaviour did you expect instead

Works as expected.

Output log

Any additional information you'd like to impart

I see two options to fix this:

  1. Change $HOME to /home/aptly
root@stage-packages-api:~# cat ./test.rb
#!/opt/puppetlabs/puppet/bin/ruby

require 'puppet'

puts Puppet::Util::Execution.execute('aptly -raw=true repo list', uid: 450, gid: 450, custom_environment: { 'HOME': '/home/aptly' })
root@stage-packages-api:~# ./test.rb
testing
  1. Add -config $config_filepath
root@stage-packages-api:~# cat ./test.rb
#!/opt/puppetlabs/puppet/bin/ruby

require 'puppet'

puts Puppet::Util::Execution.execute('aptly -raw=true repo list -config /etc/aptly.conf', uid: 450, gid: 450)
root@stage-packages-api:~# ./test.rb
testing
@baurmatt
Copy link
Author

baurmatt commented Oct 22, 2018

I will supply a PR implementing version 2 :)

baurmatt added a commit to syseleven/puppet-aptly that referenced this issue Oct 22, 2018
This is needed because otherwise the aptly command might run into
permission issue with the currenty $PWD. See tubemogul#62 for more information.

Fixes tubemogul#62.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant