Search code examples
amazon-web-servicesamazon-ec2puppeterbaws-sdk

AWS ec2 instance(Bare Metal) Provisioning with Puppet 4.5.1(OpenSource) not working


I am trying to provision aws ec2 instance with my puppet master. I want to utilize user_data field provided by aws-sdk and install puppet-agent on the node. For now I am only able to create an instance with the help of puppet.

ec2_instance { 'p-node':
  ensure        => running,
  region        => 'ap-southeast-1',
  image_id      => 'ami-25c00c46',
  key_name      => 'POC-KeyPair',
  instance_type => 't2.micro',
  security_groups => 'launch-wizard-1',
  subnet        => 'dashboard-pub-subnet-1',
  user_data     => template('agent-pe-userdata.erb'),
}

agent-pe-userdata.erb

#!/bin/bash

PE_MASTER='<%= @pe_master_hostname %>'

PE_CERTNAME=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)

curl -sk https://$PE_MASTER:8140/packages/current/install.bash | /bin/bash -s agent:certname=$PE_CERTNAME

In my case puppet is not able to find the templatedir option provided by puppet.

#puppet apply site.pp --test --templatedir templates
Error: Could not parse application options: invalid option: --templatedir

Kindly suggest whats I am doing wrong here.

Thanks in advance.


Solution

  • I placed "agent-pe-userdata.erb" file in the wrong path. It should be inside puppet/templates folder.