Unable to execute the sudo user command

806 views
Skip to first unread message

S Mullai Arasu

unread,
Aug 31, 2016, 3:47:35 PM8/31/16
to rundeck-discuss
Hi ,

I am new to the rundeck , I need support in configuring the rundeck server to execute the sudo commands.

OBJECTIVE:
To execute the system administrative commands using the sudo permission in the AWS EC2 instance since only ec2-user is allowed


STEPS I HAVE PERFORMED
=========================
I have followed below steps as defined in the Rundeck Documentation below link

Secondary Sudo Password Authentication


You can configure the way the Sudo Password Authentication works by setting these properties at the Node, Project or Rundeck scopes. Simply set the attribute name on a Node, the project.NAME in project.properties, or framework.NAME in framework.properties:

  • sudo-command-enabled - set to "true" to enable Sudo Password Authentication.
  • sudo-command-pattern - a regular expression to detect when a command execution should expect to require Sudo authentication. Default pattern is^sudo$

Below is my configuration in Project.properties file
=========================================================================
project.description=New project to Test the data 
project.name=Amazon-Dryrun
project.nodeCache.delay=30
project.nodeCache.enabled=true
project.ssh-authentication=privateKey
project.ssh-key-storage-path=keys/aws-XXXXX.pem
project.ssh.user=ec2-user
resources.source.1.config.assumeRoleArn=arn\:aws\:iam\:\:XXXXXXX\:role/AWS-RUNDECK-ROLE
resources.source.1.config.httpProxyPort=80
resources.source.1.config.mappingFile=/etc/rundeck/mappingfile.cfg
resources.source.1.config.refreshInterval=30
resources.source.1.config.runningOnly=false
resources.source.1.config.useDefaultMapping=false
resources.source.1.type=aws-ec2
resources.source.2.config.file=/var/rundeck/projects/Amazon-Dryrun/etc/resources.xml
resources.source.2.config.format=resourcexml
resources.source.2.config.generateFileAutomatically=false
resources.source.2.config.includeServerNode=false
resources.source.2.config.requireFileExists=false
resources.source.2.type=file
service.FileCopier.default.provider=jsch-scp
service.NodeExecutor.default.provider=jsch-ssh
sudo-command-enabled=true
sudo-command-pattern=^sudo$

Below is the job configuration file I am using to execute the job

<joblist>
  <job>
    <context>
      <options preserveOrder='true'>
        <option enforcedvalues='true' name='Department' values='Dept1,Dept2,Dept3,Dept4' />
        <option name='Resource_ID' />
      </options>
    </context>
    <description></description>
    <dispatch>
      <excludePrecedence>true</excludePrecedence>
      <keepgoing>false</keepgoing>
      <rankOrder>ascending</rankOrder>
      <threadcount>1</threadcount>
    </dispatch>
    <executionEnabled>true</executionEnabled>
    <id>cf3a0564-cf32-4d40-9799-5649350360ac</id>
    <loglevel>INFO</loglevel>
    <name>Tag-ec2Resource</name>
    <nodefilters>
      <filter>tagName:DEV-RUNDECK .*</filter>
    </nodefilters>
    <nodesSelectedByDefault>true</nodesSelectedByDefault>
    <scheduleEnabled>false</scheduleEnabled>
    <sequence keepgoing='false' strategy='node-first'>
      <command>
        <scriptargs> ${option.Resource_ID}  ${option.Department} </scriptargs>
        <scriptfile>/bin/setTag.sh</scriptfile>
        <scriptinterpreter argsquoted='true'>sudo</scriptinterpreter>
      </command>
    </sequence>
    <uuid>cf3a0564-cf32-4d40-9799-5649350360ac</uuid>
  </job>
</joblist>



RESULTS
=========================
Below is the error I am getting while when I run the job

Starting SSH Connection: ec2-...@xxxxxxxxxx.compute-1.amazonaws.com (DEV-RUNDECK)
12:17:50sudo: sorry, you must have a tty to run sudo
12:17:51Disconnecting from XXXXXXXXXXcompute-1.amazonaws.com port 22
12:17:51Remote command failed with exit status 1

S Mullai Arasu

unread,
Aug 31, 2016, 5:32:40 PM8/31/16
to rundeck-discuss
Hi , The sudo issue resolved after editing the below lines of the project.properties file w

sudo-command-enabled=true
sudo-command-pattern=^sudo$

with the below lines
project.sudo-command-enabled=true
project.sudo-command-pattern=^sudo$

Thanks
Mullai Arasu

Reply all
Reply to author
Forward
0 new messages