| task: #!/bin/sh instance_username="$PT_instance_username" if [ -z "${instance_username}" ] ; then instance_username="tester" fi export git_dir="/home/$instance_username/git" if [ ! -d $git_dir/puppet-metrics-viewer ]; then
- echo "git clone https://github.com/puppetlabs/puppet-metrics-viewer.git /home/$instance_username/git/puppet-metrics-viewer" > /tmp/gclone
git clone https://github.com/puppetlabs/puppet-metrics-viewer.git /home/$instance_username/git/puppet-metrics-viewer chown -R $instance_username /home/$instance_username/git/puppet-metrics-viewer chgrp -R $instance_username /home/$instance_username/git/puppet-metrics-viewer fi
run: ✗ bolt task run p9_instance_setup::setup_metrics_viewer --nodes 10.234.0.19 --user centos --private-key ~/.ssh/id_rsa-acceptance --no-host-key-check --tty --run-as fanny instance_username=fanny Started on 10.234.0.19... Finished on 10.234.0.19: fatal: Could not change back to '/home/centos': Permission denied { } Successful on 1 node: 10.234.0.19 Ran on 1 node in 2.53 seconds Normally this task is run from a plan which is why the oddness of the connection user being centos... the larger picture creates the user before this and installs git and all that. Then near the end it calls this task to clone the repo... I originally tried to use the run_as <user> so that I wouldn't have to mess with cleaning up the permissions. But it seemed to create the directory that the git clone should create, but it was empty. I debugged down to this level which does the same but gives the error. The workaround in this case it to run_as root and then have the task fix the permissions. |