Description of problem: While trying to do a puppet run via REX using non-root user on Satellite 6.12 fails with below error 1:/var/tmp/foreman-ssh-cmd-98727ed0-6d73-492f-a0b0-375e1997bcd6/script: line 1: puppet: command not found 2:Exit status: 127 Version-Release number of selected component (if applicable): Satellite 6.12.1 Puppet 7 How reproducible: Easily Reproducible Steps to Reproduce: 1. Install Satellite 6.12.1 2. Enable puppet on Satellite server. 3. Configure a Puppet client & create 'rexuser' 4. Set effective user to 'rexuser' for Puppet client for remote execution. 5. Invocate the Remote execution from Satellite WebUI as below Job category : Puppet Job template : Puppet Run Once - Script Default Actual results: Puppet run fails with error "puppet: command not found" Expected results: Puppet Run should work fine Additional info:
If I am correct, * The issue happened with the non-root user as The PATH env var of the Non-Root user would not have the /opt/puppetlabs/bin and if I am not wrong when satellite SSH to rexuser and sudo to root, It will inherit the PATH var from rexuser * So that is why, "puppet: command not found" * For root user i.e. ( SSH User = root ) it works fine as , The PATH env var of root will have the puppetlabs binary path in it. Looking at the code: https://github.com/theforeman/foreman_remote_execution/blob/master/app/views/templates/script/puppet_run_once.erb And we export the PATH variable to include the full path of puppet on for Debian only. <% if @host.operatingsystem.family == 'Debian' -%> export PATH=/opt/puppetlabs/bin:$PATH <% end -%> puppet agent --onetime --no-usecacheonfailure --no-daemonize <%= input("puppet_options") %> I expect "/etc/profile.d/puppet-agent.sh" to be loaded in OS env when REX stuff happens ( as mentioned in https://bugzilla.redhat.com/show_bug.cgi?id=1527627#c7 ). But perhaps that is not happening for non-root users and due to the same , The easiest way to solve this would be to have the "export PATH" applied for redhat based systems as well, in the job template. ( we can simply remove the if clause i guess or add a new one for RedHat )
Could be. There is also a quite high chance that it behaves differently depending on which effective user method you use and whether you use ssh or pull. Hardcoding an extension of PATH would be the easy way out. Also in the meantime, the customer can fix this for themselves by cloning the template, making the changes in the clone and then assigning that template to puppet_run_host feature.
True. The customer had mentioned that the Ansible-based Puppet run works fine ( even via non-root ssh user ). I will ask the engineer the verify with * SSH * Pull * Ansible And then share the observations here ( via non-root user as SSH user ) About, ~~ Also in the meantime, the customer can fix this for themselves by cloning the template, making the changes in the clone and then assigning that template to puppet_run_host feature. ~~ I believe the end-user is aware of it but he would like to have it fixed via Default Templates only.
Hi, I have done the below tests using "default templates" while "effective_user_method" is sudo. ========================================================================================================================= Job Category Job Template User Error Success ========================================================================================================================= Puppet Puppet Run Once – Script Default rexuser puppet: command not found No Puppet Puppet Run Once – Script Default root No Error Yes ------------------------------------------------------------------------------------------------------------------------- Ansible Puppet Puppet Run Once – Ansible Default rexuser [Errno 2] No such file or directory No Ansible Puppet Puppet Run Once – Ansible Default root No Error Yes ------------------------------------------------------------------------------------------------------------------------- Ansible Commands Run Comman – Ansible Default rexuser /bin/sh: puppet: command not found No (Command # puppet agent -tv) Ansible Commands Run Comman – Ansible Default root No Error Yes (Command # puppet agent -tv) -------------------------------------------------------------------------------------------------------------------------