Skip to content

Commit 6cf9ba5

Browse files
authored
Merge pull request #402 from ComputeCanada/issue399
Fix issue 399
2 parents 675c87b + 9c933ac commit 6cf9ba5

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

common/configuration/puppet.yaml.tftpl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,21 @@ runcmd:
102102
- rm -rf /etc/puppetlabs/code/environments/production
103103
- git clone ${puppetenv_git} /etc/puppetlabs/code/environments/main
104104
- ln -s /etc/puppetlabs/code/environments/main /etc/puppetlabs/code/environments/production
105-
- "(cd /etc/puppetlabs/code/environments/production; git fetch origin ${puppetenv_rev}; git switch -C ${puppetenv_rev} FETCH_HEAD)"
105+
- |
106+
(
107+
cd /etc/puppetlabs/code/environments/production
108+
if git fetch origin ${puppetenv_rev} 2> /dev/null; then
109+
git switch -C ${puppetenv_rev} FETCH_HEAD
110+
elif ! git checkout ${puppetenv_rev}; then
111+
echo 'WARNING - config_version=${puppetenv_rev} is invalid. puppet environment defaulted to latest tag' | tee -a /etc/motd
112+
git checkout $(git tag | sort -n | tail -n1)
113+
fi
114+
)
106115
- mkdir -p /etc/puppetlabs/data /etc/puppetlabs/facts
107116
- chgrp -R puppet /etc/puppetlabs/data /etc/puppetlabs/facts
108117
- ln -sf /etc/puppetlabs/data/{user_data,user_data.yaml,terraform_data.yaml} /etc/puppetlabs/code/environments/production/data/
109118
- ln -sf /etc/puppetlabs/facts/terraform_facts.yaml /etc/puppetlabs/code/environments/production/site/profile/facts.d
110-
# We use r10k solely to install the modules of the main branch environment.
119+
# We use r10k solely to install the modules of the production puppet environment.
111120
- /opt/puppetlabs/puppet/bin/r10k puppetfile install --moduledir=/etc/puppetlabs/code/environments/production/modules --puppetfile=/etc/puppetlabs/code/environments/production/Puppetfile
112121
%{ if puppetfile != "" ~}
113122
- /opt/puppetlabs/puppet/bin/r10k puppetfile install --moduledir=/etc/puppetlabs/code/modules --puppetfile=/etc/puppetlabs/code/Puppetfile

0 commit comments

Comments
 (0)