Last active
February 23, 2018 00:52
-
-
Save jamtur01/ca5eaf1e142e97d56e5bb171536b430a to your computer and use it in GitHub Desktop.
Running local Serverspec tests via Packer with thanks to Rickard von Essen
This file contains 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
{ | |
"variables": { | |
"aws_access_key": "", | |
"aws_secret_key": "" | |
}, | |
"builders": [{ | |
"type": "amazon-ebs", | |
"access_key": "{{user `aws_access_key`}}", | |
"secret_key": "{{user `aws_secret_key`}}", | |
"region": "us-east-1", | |
"source_ami": "ami-a025aeb6", | |
"instance_type": "t2.micro", | |
"ssh_username": "ubuntu", | |
"ami_name": "serverspec-ami {{timestamp | clean_ami_name}}" | |
}], | |
"provisioners": [{ | |
"type": "shell", | |
"script": "install-puppet.sh" | |
}, | |
{ | |
"source": "hieradata", | |
"type": "file", | |
"destination": "/tmp" | |
}, | |
{ | |
"type": "puppet-masterless", | |
"manifest_file": "manifests/site.pp", | |
"puppet_bin_dir": "/opt/puppetlabs/bin", | |
"hiera_config_path": "hiera.yaml", | |
"module_paths": [ | |
"modules" | |
] | |
}, | |
{ | |
"type": "shell", | |
"inline": [ | |
"ifconfig enp0s5 | grep inet\\ | sed -e 's/.*inet \\([^ ]*\\).*/export TARGET_HOST=\\1/' > /tmp/ip" | |
] | |
}, | |
{ | |
"type": "file", | |
"source": "/tmp/ip", | |
"destination": "ip", | |
"direction": "download" | |
}, | |
{ | |
"command": ". ip && cd tests && echo $TARGET_HOST && rbenv exec rake spec", | |
"type": "shell-local" | |
} | |
] | |
} |
This file contains 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
require 'serverspec' | |
set :backend, :ssh | |
set :host, ENV['TARGET_HOST'] | |
set :ssh_options, { | |
:password => 'vagrant', | |
:user => 'vagrant', | |
:paranoid => false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment