Puppet Setup SSH Keys

I am new to puppet. With the help of google i am completing puppet task.

Task: Puppet Setup SSH Keys:
Below is the main file
[root@jump_host manifests]# cat blog.pp
node ‘stapp01.stratos.xfusioncorp.com’{
include ssh_node1
}
node ‘stapp02.stratos.xfusioncorp.com’{
include ssh_node2
}
node ‘stapp03.stratos.xfusioncorp.com’{
include ssh_node3
}

Below is the module manifest file for stapp01. Same way created for stapp02, stapp03.

root@jump_host manifests]# cat init.pp
class ssh_node1{
ssh_authorized_key { ‘root@jump_host’:
user => ‘tony’,
type => ‘ssh-rsa’,
key => ‘AAAAB3NzaC1yc2EAAAADAQABAAABAQDINR0CKRPLWt7fyxm2diVL3mTTQYVxMOlz57G0TVFO6qrK9KqBh2HXstECPyex71uwDUkYR+joG1OHwvE6n2TQm4PhUa9cIp+Ppp6UJOJ8oACB2rNIqwjMVrjVjq3kLKP+nDSJNo5Dgclth3jd6FL40leTboxi1ZflrZ4k0cNYpcNEFoSiYGrb52V05YcXbnrWbDJkn6ObrfanuyeJj/ppoYQ+st36Sqo8FEhEOx3U4cC1vnFZaiIjiT3UUR4TlHYuhM16YxNHbBdSLFc4ABkm8PMlc2o4sDzCv8zD1V2Ka4C21hUBCfyfk1INYt5FxT8VaFc7gW/Vb6IHJQNZTTOn’,
}
}

Then ran puppet agent -t on all app servers. SSH key copied and able to login from jump server to all app node with their sudo users. But task marked failed.

Kindly let me know what i tried is correct or not.

Because of above method all my puppet task are failed even if i got expected output.

Can someone plz update on my above query.

Hello, nithyaks
Don’t worry. They will investigate cause of failure. But according to me you need to store ssh key into their $HOME/.ssh path.

In question they mentioned password less authentication from master to agent node for their sudo users. After completing this task i was able to do ssh from master node to other node with their corresponding sudo users.

Kindly let me know why my Puppet Setup SSH keys task show failed even ssh key was setup to app node

Kindly let me know why my Puppet Setup SSH keys task show failed even ssh key was setup to app node.

@nithyaks Could you please let me know if you already have your today’s task assigned ? We can mark this one and puppet symlink task Pending for you to retry.

Kindly mark it pending. I will try again

@Inderpreet Kindly mark it pending. I will try again

@nithyaks Its done. Please check.

Thanks a lot. I have completed both the task

@Inderpreet
Thanks a lot. I have completed the task

@Inderpreet

Hi Inderpreet! A quick question.
<NAME/COMMENT>
Can the resource title be given anything? On jumphost I noticed for id_rsa.pub, the name/comment is given as root@jump_host at the end. Do we have to specify the same name while copying it to all app servers or not needed? Or can we also give tony@stapp01 for that respective server.
Can you please clarify?

I am stuck on this Task, i dont deal with puppet before and more focus to learn ansible. When i set up all i end here:
class ssh_node1
ssh_authorized_key { ‘root@jump_host’:
user => ‘tony’,
ensure => ‘present’,
type => ‘ssh-rsa’,
key => ‘AAAAB3NzaC1yc2EAAAADAQABAAABAQDpp6vk6zTiOHoHTZf/5sZupOdS0UxmthMk4oI4jyRdwBa7CkLIzLpZKoPeCzJJbks00jxiWY634uAdTFvGC0USF4UV4R8Up1k/Yk7XzrPiHX1UdBWoEMvjUsYWnIvHQFiTqpSWbkNAoa2rRAk3Yftw4G2tDktFqhdDLelPjB+/oCzxo7NeffGKNVpHicrajTTOM+DN2D+vUtOYA9RGx4n6UyDiUgH5a4TU7yHP5LuTYpjEb+z4c2+v2SzpDhEHNDlWkrO9OK25SKrhhL/yEQ1Irihry+3SCzZ18XtaH9CY0q+5rmqehRGIkpYbkDqCsvsSEdwGD07PCOge5TmXGuNx’
}
class ssh_node2
ssh_authorized_key {‘root@jump_host’:
user => ‘steve’,
ensure => ‘present’,
type => ‘ssh-rsa’,
key => ‘AAAAB3NzaC1yc2EAAAADAQABAAABAQDpp6vk6zTiOHoHTZf/5sZupOdS0UxmthMk4oI4jyRdwBa7CkLIzLpZKoPeCzJJbks00jxiWY634uAdTFvGC0USF4UV4R8Up1k/Yk7XzrPiHX1UdBWoEMvjUsYWnIvHQFiTqpSWbkNAoa2rRAk3Yftw4G2tDktFqhdDLelPjB+/oCzxo7NeffGKNVpHicrajTTOM+DN2D+vUtOYA9RGx4n6UyDiUgH5a4TU7yHP5LuTYpjEb+z4c2+v2SzpDhEHNDlWkrO9OK25SKrhhL/yEQ1Irihry+3SCzZ18XtaH9CY0q+5rmqehRGIkpYbkDqCsvsSEdwGD07PCOge5TmXGuNx’
}
class ssh_node3
ssh_authorized_key {‘root@jump_host’:
user => ‘banner’,
ensure => ‘present’,
type => ‘ssh-rsa’,
key => ‘AAAAB3NzaC1yc2EAAAADAQABAAABAQDpp6vk6zTiOHoHTZf/5sZupOdS0UxmthMk4oI4jyRdwBa7CkLIzLpZKoPeCzJJbks00jxiWY634uAdTFvGC0USF4UV4R8Up1k/Yk7XzrPiHX1UdBWoEMvjUsYWnIvHQFiTqpSWbkNAoa2rRAk3Yftw4G2tDktFqhdDLelPjB+/oCzxo7NeffGKNVpHicrajTTOM+DN2D+vUtOYA9RGx4n6UyDiUgH5a4TU7yHP5LuTYpjEb+z4c2+v2SzpDhEHNDlWkrO9OK25SKrhhL/yEQ1Irihry+3SCzZ18XtaH9CY0q+5rmqehRGIkpYbkDqCsvsSEdwGD07PCOge5TmXGuNx’
}
node ‘stapp01.stratos.xfusioncorp.com’{
include ssh_node1
}
node ‘stapp02.stratos.xfusioncorp.com’{
include ssh_node2
}
node ‘stapp03.stratos.xfusioncorp.com’{
include ssh_node3
}

[root@stapp01 tony]# puppet agent -t
Info: Using configured environment ‘production’
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Could not parse for environment production: Syntax error at ‘ssh_authorized_key’ (file: /etc/puppetlabs/code/environments/production/manifests/official.pp, line: 2, column: 1) on node stapp01.stratos.xfusioncorp.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

What i am doing wrong?

Hello, @martin
Did you created a key before running the manifest file from the ssh-keygen?

Hello,

there is a ssh key already. I took it from id_rsa.pub so i wasn’t in charge to create one. I think the problem is with my manifest but i am not an absolute puppet newbie thats why i get sweat on my head when i get new tasks and they contain puppet :slightly_smiling_face:

class ssh_node1 {
ssh_authorized_key { ‘root@jump_host’:
user => ‘tony’,
ensure => ‘present’,
type => ‘ssh-rsa’,
key => ‘AAAAB3NzaC1yc2EAAAADAQABAAABAQDpp6vk6zTiOHoHTZf/5sZupOdS0UxmthMk4oI4jyRdwBa7CkLIzLpZKoPeCzJJbks00jxiWY634uAdTFvGC0USF4UV4R8Up1k/Yk7XzrPiHX1UdBWoEMvjUsYWnIvHQFiTqpSWbkNAoa2rRAk3Yftw4G2tDktFqhdDLelPjB+/oCzxo7NeffGKNVpHicrajTTOM+DN2D+vUtOYA9RGx4n6UyDiUgH5a4TU7yHP5LuTYpjEb+z4c2+v2SzpDhEHNDlWkrO9OK25SKrhhL/yEQ1Irihry+3SCzZ18XtaH9CY0q+5rmqehRGIkpYbkDqCsvsSEdwGD07PCOge5TmXGuNx’
}
}

You have to just enclosed with the curly brackets. Without {} it’s messing up with other defined classes @martin
Let me know if you face any issues.

Thanks @player001 that helped me a lot, i know why i dont like puppet :slight_smile: