Skip to content

Commit

Permalink
Add users keys as authorized keys for yumrepostage
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms committed Oct 3, 2023
1 parent a416fb2 commit 2046338
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions puppet/modules/secure_ssh/manifests/receiver_setup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
Optional[String] $foreman_search = undef,
Array[Stdlib::IP::Address] $allowed_ips = [],
String $ssh_key_name = "${name}_key",
Array[String] $authorized_keys = [],
) {
# Disable password, we want this to be keys only
user { $user:
Expand Down
18 changes: 10 additions & 8 deletions puppet/modules/secure_ssh/manifests/rsync/receiver_setup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@
Optional[String] $foreman_search = undef,
Array[Stdlib::IP::Address] $allowed_ips = [],
String $script_content = "# Permit transfer\n\$SSH_ORIGINAL_COMMAND\n",
Array[String] $authorized_keys = [],
) {
secure_ssh::receiver_setup { $name:
user => $user,
groups => $groups,
homedir => $homedir,
homedir_mode => $homedir_mode,
foreman_search => $foreman_search,
allowed_ips => $allowed_ips,
ssh_key_name => "rsync_${name}_key",
script_content => template('secure_ssh/script_rsync.erb'),
user => $user,
groups => $groups,
homedir => $homedir,
homedir_mode => $homedir_mode,
foreman_search => $foreman_search,
allowed_ips => $allowed_ips,
ssh_key_name => "rsync_${name}_key",
script_content => template('secure_ssh/script_rsync.erb'),
authorized_keys => $authorized_keys,
}

file { "${homedir}/rsync_cache":
Expand Down
4 changes: 4 additions & 0 deletions puppet/modules/secure_ssh/templates/auth_keys.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
# Facts hash from Foreman
array = @ip_data['results'].values.map{|a| a.values_at('external_ip4', 'external_ip6') }.flatten.compact
end
users = @authorized_keys
-%>
<% array.sort.each do |ip| -%>
from="<%= ip %>",command="<%= @homedir %>/bin/secure_<%= @name %>" ssh-rsa <%= @pub_key %> <%= ip %>_secure_<%= @name %>
<% end -%>
<% users.sort.each do |user_key| -%>
command="<%= @homedir %>/bin/secure_<%= @name %>" <%= user_key %>
<% end -%>
15 changes: 10 additions & 5 deletions puppet/modules/web/manifests/vhost/stagingyum.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@
},
]

$authorized_keys = flatten(['ehelms', 'evgeni', 'ekohl'].map |$name| {
split(file("users/${name}-authorized_keys"), "\n")
})

secure_ssh::rsync::receiver_setup { $user:
user => $user,
homedir => $home,
homedir_mode => '0750',
foreman_search => 'host ~ node*.jenkins.*.theforeman.org and (name = external_ip4 or name = external_ip6)',
script_content => template('web/deploy-stagingyum.sh.erb'),
user => $user,
homedir => $home,
homedir_mode => '0750',
foreman_search => 'host ~ node*.jenkins.*.theforeman.org and (name = external_ip4 or name = external_ip6)',
script_content => template('web/deploy-stagingyum.sh.erb'),
authorized_keys => $authorized_keys,
}

web::vhost { 'stagingyum':
Expand Down

0 comments on commit 2046338

Please sign in to comment.