Created
March 2, 2018 06:11
-
-
Save RichardBronosky/50caf2f91362a5ce3ff3b03e1513e8e0 to your computer and use it in GitHub Desktop.
Chef Bootstrapping an EC2 instance immediately and handsfree using cloud-init user-data
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
#cloud-config | |
# | |
# This is an example file to automatically install chef-client and run a | |
# list of recipes when the instance boots for the first time. | |
# Make sure that this file is valid yaml before starting instances. | |
# It should be passed as user-data when starting the instance. | |
# | |
# This example assumes the instance is 16.04 (xenial) | |
# The default is to install from packages. | |
# Key from https://packages.chef.io/chef.asc | |
apt: | |
sources: | |
source1: "deb http://packages.chef.io/repos/apt/stable $RELEASE main" | |
key: | | |
-----BEGIN PGP PUBLIC KEY BLOCK----- | |
Version: GnuPG v1.4.12 (Darwin) | |
Comment: GPGTools - http://gpgtools.org | |
mQGiBEppC7QRBADfsOkZU6KZK+YmKw4wev5mjKJEkVGlus+NxW8wItX5sGa6kdUu | |
twAyj7Yr92rF+ICFEP3gGU6+lGo0Nve7KxkN/1W7/m3G4zuk+ccIKmjp8KS3qn99 | |
dxy64vcji9jIllVa+XXOGIp0G8GEaj7mbkixL/bMeGfdMlv8Gf2XPpp9vwCgn/GC | |
JKacfnw7MpLKUHOYSlb//JsEAJqao3ViNfav83jJKEkD8cf59Y8xKia5OpZqTK5W | |
ShVnNWS3U5IVQk10ZDH97Qn/YrK387H4CyhLE9mxPXs/ul18ioiaars/q2MEKU2I | |
XKfV21eMLO9LYd6Ny/Kqj8o5WQK2J6+NAhSwvthZcIEphcFignIuobP+B5wNFQpe | |
DbKfA/0WvN2OwFeWRcmmd3Hz7nHTpcnSF+4QX6yHRF/5BgxkG6IqBIACQbzPn6Hm | |
sMtm/SVf11izmDqSsQptCrOZILfLX/mE+YOl+CwWSHhl+YsFts1WOuh1EhQD26aO | |
Z84HuHV5HFRWjDLw9LriltBVQcXbpfSrRP5bdr7Wh8vhqJTPj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0oWjpaLC | |
MpmrR3Ny2wkmO0h+vgri9uIP06ODWIhJBBgRAgAJBQJKaQu0AhsMAAoJEClAq6mD | |
74Jq4hIAoJ5KrYS8kCwj26SAGzglwggpvt3CAJ0bekyky56vNqoegB+y4PQVDv4K | |
zA== | |
=IxPr | |
-----END PGP PUBLIC KEY BLOCK----- | |
chef: | |
# Boolean to run or not run chef (defaults to false) | |
exec: true | |
# List of strings (defaults to ["-d", "-i", "1800", "-s", "20"]) | |
exec_arguments: | |
- "-d" | |
- "1" # Note this small change to the default which causes the daemon to perform the first run in 1 second rather than <interval> seconds | |
- "-i" | |
- "1800" | |
- "-s" | |
- "20" | |
# Valid values are 'gems' and 'packages' and 'omnibus' | |
install_type: "omnibus" | |
# Boolean: run 'install_type' code even if chef-client | |
# appears already installed. | |
force_install: false | |
# Chef settings | |
server_url: "https://chef.my-org.org" | |
# Node Name | |
# Defaults to the instance-id if not present | |
node_name: "bastion2" | |
# Environment | |
# Defaults to '_default' if not present | |
environment: "devops" | |
# Default validation name is chef-validator | |
validation_name: "admin" | |
# if validation_cert's value is "system" then it is expected | |
# that the file already exists on the system. | |
validation_cert: | | |
-----BEGIN RSA PRIVATE KEY----- | |
REDACTED | |
-----END RSA PRIVATE KEY----- | |
# A run list for a first boot json, an example (not required) | |
run_list: | |
- "recipe[my-org_common]" | |
- "recipe[my-org_users]" | |
# if install_type is 'omnibus', change the url to download | |
omnibus_url: "https://www.chef.io/chef/install.sh" | |
# if install_type is 'omnibus', pass pinned version string | |
# to the install script | |
#omnibus_version: "13.8.0" | |
# Capture all subprocess output into a logfile | |
# Useful for troubleshooting cloud-init issues | |
output: {all: '| tee -a /var/log/cloud-init-output.log'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment