Jira (BOLT-1336) simple task fails trying to change back to user it connected with...

2 views
Skip to first unread message

Randell Pelak (JIRA)

unread,
May 22, 2019, 8:23:03 PM5/22/19
to puppe...@googlegroups.com
Randell Pelak created an issue
 
Puppet Task Runner / Bug BOLT-1336
simple task fails trying to change back to user it connected with...
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2019/05/22 5:22 PM
Priority: Normal Normal
Reporter: Randell Pelak

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

  1. 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.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages