Skip to content

Commit

Permalink
Merge pull request #2892 from justinstoller/code-scripts
Browse files Browse the repository at this point in the history
(maint) Fix code_scripts acceptance test
  • Loading branch information
justinstoller authored Oct 8, 2024
2 parents 0e43d50 + 32d8338 commit 03e8588
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions acceptance/suites/tests/code_commands/code_scripts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ def cicsetting(present_or_absent='present')
on master, 'puppet apply /tmp/config_code_id_command_script_disable.pp'
reload_server

on(master, 'rm -rf /root/.ssh/gittest_rsa*', :accept_all_exit_codes => true)
on(master, 'puppet resource user git ensure=absent')
on(master, "rm -rf #{git_repo_parentdir}", :accept_all_exit_codes => true)
on(master, "rm -rf #{git_local_repo}", :accept_all_exit_codes => true)
on(master, 'rm -rf /home/git/.ssh/authorized_keys', :accept_all_exit_codes => true)

#remove code_* scripts.
on(master, 'rm -rf /opt/puppetlabs/server/apps/puppetserver/code-id-command_script.sh')
Expand All @@ -53,11 +51,6 @@ def cicsetting(present_or_absent='present')
on(master, 'puppet resource file /etc/puppetlabs/code ensure=directory')
end

step 'SETUP: Generate a new ssh key for the root user account to use with the git server'
on(master, 'rm -f /root/.ssh/gittest_rsa')
on(master, 'ssh-keygen -t rsa -V +1d -f /root/.ssh/gittest_rsa -N ""')
gittest_key=on(master, "awk '{print $2}' /root/.ssh/gittest_rsa.pub").stdout.chomp

step 'SETUP: Install and configure git server' do
on(master, 'puppet module install puppetlabs-git')
git_config=<<-GIT
Expand All @@ -77,31 +70,12 @@ def cicsetting(present_or_absent='present')
require => User['git'],
}
ssh_authorized_key { 'root@#{hostname}' :
user => 'git',
ensure => present,
type => 'ssh-rsa',
key => '#{gittest_key}',
require => File['/home/git'],
}
class { 'git': }
GIT
create_remote_file(master, '/tmp/git_setup.pp', git_config)
on master, puppet_apply('/tmp/git_setup.pp')
end

step 'SETUP: Write out ssh config...' do
ssh_config=<<-SSHCONFIG
Host #{hostname} #{fqdn}
User git
IdentityFile ~/.ssh/gittest_rsa
IdentitiesOnly yes
StrictHostKeyChecking no
SSHCONFIG
create_remote_file(master, '/root/.ssh/config', ssh_config)
end

step 'SETUP: Initialize the git control repository' do
on master, "chown git #{git_repo_parentdir}"
on master, "sudo -u git git init --bare #{git_repo}", :pty => true
Expand All @@ -116,13 +90,13 @@ class { 'git': }
on master, "cd #{git_local_repo} && touch .gitignore"
on master, "cd #{git_local_repo} && git add ."
on master, "cd #{git_local_repo} && git commit -m 'initial commit'"
on master, "cd #{git_local_repo} && git remote add origin git@#{fqdn}:#{git_repo}"
on master, "cd #{git_local_repo} && git remote add origin file://#{git_repo}"
on master, "cd #{git_local_repo} && git push origin master"
end

step 'SETUP: Install and configure r10k, and perform the initial commit' do
on master, "puppet config set server #{fqdn}"
on master, '/opt/puppetlabs/puppet/bin/gem install r10k'
on master, '/opt/puppetlabs/puppet/bin/gem install r10k --no-document'
on master, "cd #{git_local_repo} && git checkout -b production"
r10k_yaml=<<-R10K
# The location to use for storing cached Git repos
Expand All @@ -133,7 +107,7 @@ class { 'git': }
# This will clone the git repository and instantiate an environment per
# branch in /etc/puppetlabs/code/environments
:my-org:
remote: git@#{fqdn}:#{git_repo}
remote: file://#{git_repo}
basedir: '/etc/puppetlabs/code/environments'
R10K
on master, 'mkdir -p /etc/puppetlabs/r10k'
Expand Down

0 comments on commit 03e8588

Please sign in to comment.