Adding AWS EC2 instance to Rundeck server

Posted: February 8, 2018 in Amazon Web Services (AWS), Linux, RunDeck

In last post we added node to Rundeck, now we’ll add EC2 instance as node

First,we need to add AWS EC2 plugin

cd /var/lib/rundeck/libext/
wget https://github.com/rundeck-plugins/rundeck-ec2-nodes-plugin/releases/download/v1.5.1/rundeck-ec2-nodes-plugin-1.5.1.jar
systemctl restart rundeckd

Now create New project-Add source-AWS EC2 Resources

1.PNG

Specify Access Key, Secret Key, Endpoint (for list of endpoint refer to https://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region)

In mapping parameters field specify:

name.selector=tags/Name;

hostname.selector=publicIcDnsName;

description.default=Ec2 node instance;

osArch.selector=architecture;

osFamily.selector=platform;

osFamily.default=unix;

osName.selector=platform;

osName.default=Linux;

username.selector=tags/Rundeck-User;

username.default=root;

ssh-keypath.default=/var/lib/rundeck/.ssh/id_rsa;

editUrl.default=https://console.aws.amazon.com/ec2/home#c=EC2&s=Instances;

attribute.publicIpAddress.selector=publicIpAddress;

attribute.publicDnsName.selector=publicDnsName;

tags.selector=tags/Rundeck-Tags

Click Save, EC2 node(s) should be visible in Rundeck

Line in projet properties

resources.source.2.config.mappingParams=name.selector\=tags/Name;hostname.selector\=publicDnsName;description.default\=Ec2 node instance;osArch.selector\=architecture;osFamily.selector\=platform;osFamily.default\=unix;osName.selector\=platform;osName.default\=Linux;username.selector\=tags/Rundeck-User;username.default\=root;ssh-keypath.default\=/var/lib/rundeck/.ssh/id_rsa;editUrl.default\=https\://console.aws.amazon.com/ec2/home\#c\=EC2&s\=Instances;attribute.publicIpAddress.selector\=publicIpAddress;attribute.publicDnsName.selector\=publicDnsName;tags.selector\=tags/Rundeck-Tags

1.PNG

On Rundeck server, if not already done create key pair

ssh-keygen –t rsa
cp /root/.ssh/id_rsa /var/lib/rundeck/.ssh/id_rsa
cp /root/.ssh/id_rsa.pub /var/lib/rundeck/.ssh/id_rsa.pub

Now, copy content id_rsa.pub to EC2 instance to /root/.ssh/authorized_keys

In Rundeck GUI, click on project-Nodes, EC2 instance should be visible

 

1.PNG

 

Also, command should be executed

 

1.PNG

 

Running AWS CLI from Rundeck server:

Install AWS CLI, on Rundeck server

On Rundeck go to commands tab in node specify local server, enter following command in interface:

 

aws configure set aws_access_key_id your_access_key
aws configure set aws_secret_access_key your_secret_key
aws configure set default.region us-west-2

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s