Morning, I am trying to do some environment setup on our developer''s virtual boxes that we use vagrant+puppet to build. We install a python app, create virtualenv''s for the different pip requirements, etc. Problem is that there are some custom bash macros that are available in our virtualenv as they are sourced in the .bashrc ie., ~panama/.bashrc {code} ... source /usr/local/python/bin/virtualenvwrapper.sh ... {code} but when my puppet scripts tries to execute those macros, it''s unable to as it can''t load the virtual env. sample.pp {code} ... exec { ''panama-eggs'': path => ["/bin","/usr/bin","/usr/local/python/bin"], environment => [''WORKON_HOME=/home/panama/.virtualenvs'', ''PIP_LOG_FILE=/tmp/pip-freeze-prod.log'', ''PIP_VIRTUALENV_BASE=/home/ panama/.virtualenvs'', ''VIRTUALENVWRAPPER_PYTHON=/usr/local/python/bin/ python''], command => "workon dev && mmf_eggs", logoutput => "true", user => "panama", group => "panama", require => [Exec["mmf-panama-install"], Exec[''symlink-panama- post-activate'']] } ... {code} results in: ... err: /Stage[main]/Panama/Exec[panama-eggs]/returns: change from notrun to 0 failed: sh: workon: command not found ... fyi # .bash_profile if [ -f ~/.bashrc ]; then source ~/.bashrc Any ideas on how to get puppet to recognize the macros in the "source / usr/local/python/bin/virtualenvwrapper.sh" for user panama? Cheers, -Kevin -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Would something along the lines of: {code} command => "bash -l -c ''sudo su - panama && workon dev && mmf_eggs''", {code} work? -Kevin On Feb 8, 6:17 am, kevin c <kcalla...@gmail.com> wrote:> Morning, > > I am trying to do some environment setup on our developer''s virtual > boxes that we use vagrant+puppet to build. We install a python app, > create virtualenv''s for the different pip requirements, etc. > > Problem is that there are some custom bash macros that are available > in our virtualenv as they are sourced in the .bashrc > > ie., > ~panama/.bashrc > {code} > ... > source /usr/local/python/bin/virtualenvwrapper.sh > ... > {code} > > but when my puppet scripts tries to execute those macros, it''s unable > to as it can''t load the virtual env. > > sample.pp > {code} > ... > exec { ''panama-eggs'': > path => ["/bin","/usr/bin","/usr/local/python/bin"], > environment => [''WORKON_HOME=/home/panama/.virtualenvs'', > ''PIP_LOG_FILE=/tmp/pip-freeze-prod.log'', ''PIP_VIRTUALENV_BASE=/home/ > panama/.virtualenvs'', ''VIRTUALENVWRAPPER_PYTHON=/usr/local/python/bin/ > python''], > command => "workon dev && mmf_eggs", > logoutput => "true", > user => "panama", > group => "panama", > require => [Exec["mmf-panama-install"], Exec[''symlink-panama- > post-activate'']] > } > ... > {code} > > results in: > ... > err: /Stage[main]/Panama/Exec[panama-eggs]/returns: change from notrun > to 0 failed: sh: workon: command not found > ... > > fyi > # .bash_profile > if [ -f ~/.bashrc ]; then > source ~/.bashrc > > Any ideas on how to get puppet to recognize the macros in the "source / > usr/local/python/bin/virtualenvwrapper.sh" for user panama? > > Cheers, > > -Kevin-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Feb 8, 6:17 am, kevin c <kcalla...@gmail.com> wrote:> Morning, > > I am trying to do some environment setup on our developer''s virtual > boxes that we use vagrant+puppet to build. We install a python app, > create virtualenv''s for the different pip requirements, etc. > > Problem is that there are some custom bash macros that are available > in our virtualenv as they are sourced in the .bashrc > > ie., > ~panama/.bashrc > {code} > ... > source /usr/local/python/bin/virtualenvwrapper.sh > ... > {code} > > but when my puppet scripts tries to execute those macros, it''s unable > to as it can''t load the virtual env.I think you are mistaking the cause of the problem, which is that the Puppet agent does not execute shell startup scripts when it applies an Exec.> sample.pp > {code} > ... > exec { ''panama-eggs'': > path => ["/bin","/usr/bin","/usr/local/python/bin"], > environment => [''WORKON_HOME=/home/panama/.virtualenvs'', > ''PIP_LOG_FILE=/tmp/pip-freeze-prod.log'', ''PIP_VIRTUALENV_BASE=/home/ > panama/.virtualenvs'', ''VIRTUALENVWRAPPER_PYTHON=/usr/local/python/bin/ > python''], > command => "workon dev && mmf_eggs", > logoutput => "true", > user => "panama", > group => "panama", > require => [Exec["mmf-panama-install"], Exec[''symlink-panama- > post-activate'']] > } > ... > {code} > > results in: > ... > err: /Stage[main]/Panama/Exec[panama-eggs]/returns: change from notrun > to 0 failed: sh: workon: command not found > ... > > fyi > # .bash_profile > if [ -f ~/.bashrc ]; then > source ~/.bashrc > > Any ideas on how to get puppet to recognize the macros in the "source / > usr/local/python/bin/virtualenvwrapper.sh" for user panama?Write it into the Exec''s command, or else make a miniscript, and have Puppet install then Exec the script. For example: command => ''. /usr/local/python/bin/virtualenvwrapper.sh; workon dev && mmf_eggs'' John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Thanks John, exec { ''panama-eggs'': path => ["/bin","/usr/bin","/usr/local/python/bin"], environment => [''WORKON_HOME=/home/panama/.virtualenvs'', ''PIP_LOG_FILE=/tmp/pip-freeze-prod.log'', ''PIP_VIRTUALENV_BASE=/home/ panama/.virtualenvs'', ''VIRTUALENVWRAPPER_PYTHON=/usr/local/python/bin/ python''], command => ". /usr/local/python/bin/virtualenvwrapper.sh; workon dev && mmf_eggs", provider => "shell", logoutput => "true", user => "panama", group => "panama", require => [Exec["mmf-panama-install"], Exec[''symlink-panama- post-activate'']] } results in debug: Executing ''/bin/sh -c "/usr/local/python/bin/ virtualenvwrapper.sh; workon dev && mmf_eggs"'' err: /Stage[main]/Panama/Exec[panama-eggs]/returns: change from notrun to 0 failed: mkdir: cannot create directory `/root/.virtualenvs'': Permission denied /bin/sh: workon: command not found Even though there already exists a /home/panama/.virtualenvs/dev virtual environment Any ideas? Thanks for the assistance, -Kevin On Feb 8, 11:00 am, jcbollinger <John.Bollin...@stJude.org> wrote:> > I think you are mistaking the cause of the problem, which is that the > Puppet agent does not execute shell startup scripts when it applies an > Exec. > > Write it into the Exec''s command, or else make a miniscript, and have > Puppet install then Exec the script. For example: > > command => ''. /usr/local/python/bin/virtualenvwrapper.sh; workon dev > && mmf_eggs'' > > John-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Feb 8, 2:13 pm, kevin c <kcalla...@gmail.com> wrote:> Thanks John, > > exec { ''panama-eggs'': > path => ["/bin","/usr/bin","/usr/local/python/bin"], > environment => [''WORKON_HOME=/home/panama/.virtualenvs'', > ''PIP_LOG_FILE=/tmp/pip-freeze-prod.log'', ''PIP_VIRTUALENV_BASE=/home/ > panama/.virtualenvs'', ''VIRTUALENVWRAPPER_PYTHON=/usr/local/python/bin/ > python''], > command => ". /usr/local/python/bin/virtualenvwrapper.sh; > workon dev && mmf_eggs", > provider => "shell", > logoutput => "true", > user => "panama", > group => "panama", > require => [Exec["mmf-panama-install"], Exec[''symlink-panama- > post-activate'']] > } > > results in > > debug: Executing ''/bin/sh -c "/usr/local/python/bin/ > virtualenvwrapper.sh; workon dev && mmf_eggs"'' > err: /Stage[main]/Panama/Exec[panama-eggs]/returns: change from notrun > to 0 failed: mkdir: cannot create directory `/root/.virtualenvs'': > Permission denied > /bin/sh: workon: command not found > > Even though there already exists a /home/panama/.virtualenvs/dev > virtual environment > > Any ideas?I think the virtualenvwrapper.sh script is failing before it defines function workon (note the "permission denied" error). When the host shell tries to execute the second part of the comand, but it still doesn''t know what "workon" is. Fix the permission problem first, and then see where you stand. It is highly suspicious that the Puppet agent, running as root, is denied permission to write in root''s home directory. You are probably running SELinux in enforcing mode. If you want to continue doing that then you can perhaps solve the problem by modifying either the command parameter or the environment setup script, but you might just need to update your SELinux policy. I''m afraid I can''t help you with the specifics. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.