Created
October 10, 2017 15:32
-
-
Save f3ew/5d311d595417b02e2b1dfae67438c27a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################################### | |
Vagrant provisioning script | |
########################################################### | |
#!/usr/bin/env bash | |
PUPPET_BIN=/opt/puppetlabs/bin/puppet | |
if [ ! -z "${FACTER_vagrant_role}" ]; then | |
echo "Applying role ${FACTER_vagrant_role}" | |
else | |
echo "WARNING: No role set. Applying base. Set the PUPPET_ROLE environment variable before running vagrant!" | |
fi | |
if [ $FACTER_vagrant_role == 'puppet_provisioner' ] ; then | |
/opt/puppetlabs/puppet/bin/gem install googleauth | |
/opt/puppetlabs/puppet/bin/gem install google-api-client | |
cp -rf /puppet/modules_vendor/puppet-google-auth/lib/ /opt/puppetlabs/puppet/cache/lib | |
cp -rf /puppet/modules_vendor/puppet-google-compute/lib/ /opt/puppetlabs/puppet/cache/lib | |
echo "Puppet is configured" | |
echo "--------------------------------------------------------------------" | |
fi | |
$PUPPET_BIN apply --verbose \ | |
--modulepath=/puppet/modules_vendor:/puppet/modules \ | |
--hiera_config=/puppet/hiera_vagrant.yaml \ | |
/puppet/manifests/site.pp | |
################################################################################## | |
Output | |
################################################################################## | |
[d.bhagat@devdas pupcloud]$ vagrant provision | |
==> test_vm: Running provisioner: shell... | |
test_vm: Running: /tmp/vagrant-shell20171010-19621-qtsstu.sh | |
==> test_vm: puppet-agent-5.3.2-1.el7.x86_64 | |
==> test_vm: Running provisioner: shell... | |
test_vm: Running: /tmp/vagrant-shell20171010-19621-ahltb6.sh | |
==> test_vm: Applying role puppet_provisioner | |
==> test_vm: Successfully installed googleauth-0.5.3 | |
==> test_vm: Parsing documentation for googleauth-0.5.3 | |
==> test_vm: Done installing documentation for googleauth after 2 seconds | |
==> test_vm: 1 gem installed | |
==> test_vm: Successfully installed google-api-client-0.15.0 | |
==> test_vm: Parsing documentation for google-api-client-0.15.0 | |
==> test_vm: Done installing documentation for google-api-client after 183 seconds | |
==> test_vm: 1 gem installed | |
==> test_vm: Puppet is configured | |
==> test_vm: -------------------------------------------------------------------- | |
==> test_vm: Info: Loading facts | |
==> test_vm: Error: Could not autoload puppet/type/gcompute_instance: cannot load such file -- google/compute/property/address_address | |
==> test_vm: Error: Evaluation Error: Error while evaluating a Resource Statement, Could not autoload puppet/type/gcompute_instance: cannot load such file -- google/compute/property/address_address at /puppet/modules/puppet_provisioner/manifests/init.pp:12:5 on node localhost.localdomain | |
The SSH command responded with a non-zero exit status. Vagrant | |
assumes that this means the command failed. The output for this command | |
should be in the log above. Please read the output to determine what | |
went wrong. | |
############################################################################################# | |
Module I'm using to create my initial provisioner | |
############################################################################################# | |
class puppet_provisioner ( | |
$cred_path = '/path/to/account.json' | |
) { | |
gauth_credential { 'mycreds': | |
path => $cred_path, | |
provider => serviceaccount, | |
scopes => [ | |
'https://www.googleapis.com/auth/compute' | |
], | |
} | |
gcompute_instance { 'puppetserver-bootstrap': | |
ensure => present, | |
machine_type => 'n1-standard-1', | |
zone => 'europe-west1-d', | |
project => 'google.com:infra-bootstrap', | |
credential => 'mycreds', | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment