Created
July 24, 2015 19:03
-
-
Save nathwill/764d58238cf7d76fb0e1 to your computer and use it in GitHub Desktop.
packer template for role-based packer builds
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
{ | |
"description": "build th base image", | |
"min_packer_version": "0.8.0", | |
"variables": { | |
"user": "centos", | |
"image": "d5f2c6b8-ae55-41d3-b9ba-15e0f2350659", | |
"flavor": "2", | |
"role1": "common", | |
"role2": "common", | |
"role3": "common", | |
"chef_environment": "staging", | |
"chef_server_url": "{{env `CHEF_SERVER_URL`}}", | |
"secret_file": "{{env `HOME`}}/.chef/encrypted_data_bag_secret", | |
"validation_client_name": "dummy", | |
"validation_key_path": "{{env `HOME`}}/.chef/dummy.pem" | |
}, | |
"builders": [ | |
{ | |
"type": "openstack", | |
"ssh_username": "{{user `user`}}", | |
"ssh_pty": true, | |
"image_name": "{{user `role2`}}-{{timestamp}}", | |
"source_image": "{{user `image`}}", | |
"flavor": "{{user `flavor`}}", | |
"networks": [ | |
"f6392107-4a9d-6797-854b-e39af2b487ae" | |
], | |
"security_groups": [ | |
"default" | |
], | |
"use_floating_ip": true, | |
"floating_ip": "123.34.45.56" | |
} | |
], | |
"provisioners": [ | |
{ | |
"type": "shell", | |
"inline": [ | |
"sudo yum -y upgrade", | |
"sudo yum clean all", | |
"sudo mkdir /etc/chef", | |
"mkdir /tmp/packer-chef-client", | |
"chmod 0755 /tmp/packer-chef-client", | |
"sudo mount -o bind /tmp/packer-chef-client /etc/chef" | |
] | |
}, | |
{ | |
"type": "file", | |
"source": "{{user `secret_file`}}", | |
"destination": "/etc/chef/encrypted_data_bag_secret" | |
}, | |
{ | |
"type": "chef-client", | |
"server_url": "{{user `chef_server_url`}}", | |
"chef_environment": "{{user `chef_environment`}}", | |
"run_list": [ | |
"role[common]", | |
"role[{{user `role1`}}]", | |
"role[{{user `role2`}}]", | |
"role[{{user `role3`}}]" | |
], | |
"validation_client_name": "{{user `validation_client_name`}}", | |
"validation_key_path": "{{user `validation_key_path`}}" | |
}, | |
{ | |
"type": "shell", | |
"inline": [ | |
"sudo systemctl disable sensu-client.service", | |
"sudo rm -rf /etc/ssh/ssh_host*" | |
] | |
} | |
] | |
} |
Author
nathwill
commented
Jul 24, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment