├── .gitignore ├── README.md ├── app ├── .vagrant │ └── machines │ │ └── lithium │ │ └── virtualbox │ │ ├── action_provision │ │ ├── action_set_name │ │ ├── id │ │ ├── index_uuid │ │ ├── private_key │ │ └── synced_folders ├── Vagrantfile └── test.php └── ops ├── apache-php.json ├── configs ├── consul_apache_php.json └── consul_mysql.json ├── consul.json ├── mysql.json ├── scripts ├── apache-php.sh ├── base.sh ├── consul.sh └── mysql.sh ├── templates ├── mysql.ctmpl └── php.ctmpl ├── terraform └── main.tf └── upstart ├── consul_bootstrap.conf ├── consul_client.conf ├── mysql_consul_template.conf └── php_consul_template.conf /.gitignore: -------------------------------------------------------------------------------- 1 | DS_Store 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # atlas-lamp-tutorial 2 | -------------------------------------------------------------------------------- /app/.vagrant/machines/lithium/virtualbox/action_provision: -------------------------------------------------------------------------------- 1 | 1.5:260b6448-d0cd-432e-9e1f-e4a5113e598f -------------------------------------------------------------------------------- /app/.vagrant/machines/lithium/virtualbox/action_set_name: -------------------------------------------------------------------------------- 1 | 1423525382 -------------------------------------------------------------------------------- /app/.vagrant/machines/lithium/virtualbox/id: -------------------------------------------------------------------------------- 1 | 260b6448-d0cd-432e-9e1f-e4a5113e598f -------------------------------------------------------------------------------- /app/.vagrant/machines/lithium/virtualbox/index_uuid: -------------------------------------------------------------------------------- 1 | 243d3f0979e54716a921335f18d3c960 -------------------------------------------------------------------------------- /app/.vagrant/machines/lithium/virtualbox/private_key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpAIBAAKCAQEA3YxNeT1K2Vg1od+3CkPH6BbZ6IPIkxH7e83xVRAbK5ZfXMc2 3 | u7CPGCDCS2NFcIt253zZdFvgGqAt53syOHzf1CRhKt6l8Nrqi8hO76zgmS8bS2m9 4 | oewIM8FVgYMFlWYBgL47TMPgCTXSAIW2muom+Ucs8sOEYm4O/bKTWbGo03wnvWQm 5 | fRovE5fXOO7eWTVrqTL7QbC86DAf1oDba5wHDQaKsR3aOhdSy8Db91WJvyZH6bqZ 6 | FCM9sh1sJ2X9xNZ4MLcZbPw2rrGjP8UuNKTiTydVRCB7iKkWjxxt1j+QOw+9KS+M 7 | 9E6ncs5VLuVO3JQ+Dsaxnpq9UO26L81r6oR9yQIDAQABAoIBAES+9ItaaY9nv7yr 8 | HrEgtzddX+C2g9afDdos3WX3yXaNAqpXZrR25PAnuiKKe1Gg9RR/uTpSCAg7DAN4 9 | Ru0gUpQRddVHoVZLl9woG9ZjXo4p/942wZEtHJ5yr4Wwklr5fB3m6Z+4aBxzhuaC 10 | l1casV1IqLnr0Xh5jk1KzE5YwnpcyFLPMZaC74Hb85q1QEjcucvxPR9tEEVgK0Co 11 | rtgqbzJRpNYWhDBOCPjvubjCrG8aMn39NcSdYfIpcrFSZYrPuybRGFKKWk73wfRx 12 | yElAPTYGz5NbNuXlOE7Eur74mlKCoT3/Haz45O3enX+hFXVhjTck8iVZ6BjeM7Ni 13 | jzKP6AECgYEA9vGPjlLWAu/5M/3fKTvJrYzxYd0nN/ZeOHRo5hqNHF/ywc+JJdQm 14 | uIm1qp+gAkcNmWMQftiK2btqqvhjHD6JnssgXi5JDa+DKXuBuyQJ10AL0X7QiPqG 15 | KqR3FGQ/c2USOxH1kslWnoN3GKq9REbxH/kHtGRpJIW5Y4B+9ZGpdVECgYEA5axQ 16 | nIZBrf4DE1XwjQ6Nv5zSgTbjjmFmI2UQtqpeyUgoPTPRM5t9EwUbRce97Fs13fUL 17 | VtYKtlk/r1LMnRQH48m9agdG1oAP2UkmsCgQYzNPz/rA0BldJ0i+m6onRZVfwIWZ 18 | GaNVRER+xbPo7xxL3yI05vEhHONLi2+UhcqqwvkCgYA947Kv39DlMZGKV0Eby3Ez 19 | PtSsS0nt+6AHlB1KNjNRfjaQHlxoD7CYpWLTXWgzyez9mVdkAw9hnFgSe2gThxTk 20 | qFH3aLBEbs13kw2jgle5C8MqgRbwjaEchNWXVbyVRip4hXq/jBhaZ+ZsVzZSK1l5 21 | QueMbXHwhlc9OdIX56bJ0QKBgQC7D+fwNKFWF2dl3j84hDwLbq09NPmOQ+Iuvego 22 | /waIpk6v2n5vrBro3OXjpdYYpglvqF/98AN1lad7ItMotOHgM7Ykn5ygpFlEPoJW 23 | Q6tlQKum17MnSyFGF8e3fZTS5eDBK48RBKk0Gx2t5OS5q7BYIsI3vvmbT7196fls 24 | Jy+B8QKBgQD2NmPPd2/jmvwD5WmCJh9iksX/PwT+mhYcBRrfBSpCBRHf+G4uVAS2 25 | OmEYH6oyZJ1eed7l/euZN22sADW38zOz0LCjZ3+u3In5bqFKy7glNYVbIZK3eTId 26 | 1CN04M/kkNHTjpNz4XB3IL9YEqDhNaXV9NMjkuzUX9wVJ7RoVhrSAA== 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /app/.vagrant/machines/lithium/virtualbox/synced_folders: -------------------------------------------------------------------------------- 1 | {"virtualbox":{"/vagrant":{"guestpath":"/vagrant","hostpath":"/Users/kiip/demos/lithium/app","disabled":false}}} -------------------------------------------------------------------------------- /app/Vagrantfile: -------------------------------------------------------------------------------- 1 | VAGRANTFILE_API_VERSION = "2" 2 | 3 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 4 | 5 | # Learn more about Scotch Box here: https://box.scotch.io/ 6 | config.vm.box = "scotch/box" 7 | config.vm.network "private_network", ip: "192.168.33.10" 8 | config.vm.hostname = "scotchbox" 9 | config.vm.synced_folder ".", "/var/www/public", :mount_options => ["dmode=777", "fmode=666"] 10 | 11 | config.push.define "atlas" do |push| 12 | push.app = "/php" 13 | end 14 | end -------------------------------------------------------------------------------- /app/test.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ops/apache-php.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "aws_access_key": "YOUR_ACCESS_KEY", 4 | "aws_secret_key": "YOUR_SECRET_KEY" 5 | }, 6 | "builders": [{ 7 | "type": "amazon-ebs", 8 | "access_key": "{{user `aws_access_key`}}", 9 | "secret_key": "{{user `aws_secret_key`}}", 10 | "region": "us-east-1", 11 | "source_ami": "ami-9a562df2", 12 | "instance_type": "t2.micro", 13 | "ssh_username": "ubuntu", 14 | "ami_name": "apache-php {{timestamp}}" 15 | }], 16 | "push": { 17 | "name": "/apache-php", 18 | "vcs": false 19 | }, 20 | "provisioners": [ 21 | { 22 | "type": "shell", 23 | "inline": [ 24 | "sudo mkdir /ops", 25 | "sudo chmod a+w /ops" 26 | ] 27 | }, 28 | { 29 | "type": "file", 30 | "source": ".", 31 | "destination": "/ops" 32 | }, 33 | { 34 | "type": "shell", 35 | "inline": [ 36 | "sudo mkdir /application", 37 | "sudo chmod a+w /application" 38 | ] 39 | }, 40 | { 41 | "type": "file", 42 | "source": "/packer/app", 43 | "destination": "/application" 44 | }, 45 | { 46 | "type": "shell", 47 | "script": "scripts/base.sh" 48 | }, 49 | { 50 | "type": "shell", 51 | "script": "scripts/debug.sh" 52 | }, 53 | { 54 | "type": "shell", 55 | "script": "scripts/apache-php.sh" 56 | } 57 | ], 58 | "post-processors": [ 59 | { 60 | "type": "atlas", 61 | "artifact": "/apache-php", 62 | "artifact_type": "aws.ami", 63 | "metadata": { 64 | "created_at": "{{timestamp}}" 65 | } 66 | } 67 | ] 68 | } 69 | -------------------------------------------------------------------------------- /ops/configs/consul_apache_php.json: -------------------------------------------------------------------------------- 1 | { 2 | "leave_on_terminate": true, 3 | "service": { 4 | "name": "web", 5 | "tags": ["php"] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /ops/configs/consul_mysql.json: -------------------------------------------------------------------------------- 1 | { 2 | "leave_on_terminate": true, 3 | "service": { 4 | "name": "database", 5 | "tags": ["mysql"] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /ops/consul.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "aws_access_key": "YOUR_ACCESS_KEY_HERE", 4 | "aws_secret_key": "YOUR_SECRET_KEY_HERE" 5 | }, 6 | "builders": [{ 7 | "type": "amazon-ebs", 8 | "access_key": "{{user `aws_access_key`}}", 9 | "secret_key": "{{user `aws_secret_key`}}", 10 | "region": "us-east-1", 11 | "source_ami": "ami-9a562df2", 12 | "instance_type": "t2.micro", 13 | "ssh_username": "ubuntu", 14 | "ami_name": "consul {{timestamp}}" 15 | }], 16 | "push": { 17 | "name": "/consul", 18 | "vcs": false 19 | }, 20 | "provisioners": [ 21 | { 22 | "type": "shell", 23 | "inline": [ 24 | "sudo mkdir /ops", 25 | "sudo chmod a+w /ops" 26 | ] 27 | }, 28 | { 29 | "type": "file", 30 | "source": ".", 31 | "destination": "/ops" 32 | }, 33 | { 34 | "type": "shell", 35 | "script": "scripts/base.sh" 36 | }, 37 | { 38 | "type": "shell", 39 | "script": "scripts/consul.sh" 40 | } 41 | ], 42 | "post-processors": [ 43 | { 44 | "type": "atlas", 45 | "artifact": "/consul", 46 | "artifact_type": "aws.ami", 47 | "metadata": { 48 | "created_at": "{{timestamp}}" 49 | } 50 | } 51 | ] 52 | } 53 | -------------------------------------------------------------------------------- /ops/mysql.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "aws_access_key": "YOUR_ACCESS_KEY", 4 | "aws_secret_key": "YOUR_SECRET_KEY" 5 | }, 6 | "builders": [{ 7 | "type": "amazon-ebs", 8 | "access_key": "{{user `aws_access_key`}}", 9 | "secret_key": "{{user `aws_secret_key`}}", 10 | "region": "us-east-1", 11 | "source_ami": "ami-9a562df2", 12 | "instance_type": "t2.micro", 13 | "ssh_username": "ubuntu", 14 | "ami_name": "mysql {{timestamp}}" 15 | }], 16 | "push": { 17 | "name": "/mysql" 18 | }, 19 | "provisioners": [ 20 | { 21 | "type": "shell", 22 | "inline": [ 23 | "sudo mkdir /ops", 24 | "sudo chmod a+w /ops" 25 | ] 26 | }, 27 | { 28 | "type": "file", 29 | "source": ".", 30 | "destination": "/ops" 31 | }, 32 | { 33 | "type": "shell", 34 | "script": "scripts/base.sh" 35 | }, 36 | { 37 | "type": "shell", 38 | "script": "scripts/debug.sh" 39 | }, 40 | { 41 | "type": "shell", 42 | "script": "scripts/mysql.sh" 43 | } 44 | ], 45 | "post-processors": [ 46 | { 47 | "type": "atlas", 48 | "artifact": "/mysql", 49 | "artifact_type": "aws.ami", 50 | "metadata": { 51 | "created_at": "{{timestamp}}" 52 | } 53 | } 54 | ] 55 | } 56 | -------------------------------------------------------------------------------- /ops/scripts/apache-php.sh: -------------------------------------------------------------------------------- 1 | # install apache php 2 | sudo apt-get -y update 3 | 4 | sudo apt-get install -y -qq \ 5 | php5 \ 6 | php5-mysql \ 7 | apache2 8 | 9 | # move application files to apache folder 10 | sudo mv /application/app/* /var/www/html 11 | 12 | # consul config 13 | echo Configuring Consul.... 14 | sudo mv /ops/configs/consul_apache_php.json /etc/consul.d/apache-php.json 15 | sudo mv /ops/upstart/consul_client.conf /etc/init/consul.conf 16 | 17 | # install consul template 18 | wget https://github.com/hashicorp/consul-template/releases/download/v0.6.5/consul-template_0.6.5_linux_amd64.tar.gz 19 | tar xzf consul-template_0.6.5_linux_amd64.tar.gz 20 | sudo mv consul-template_0.6.5_linux_amd64/consul-template /usr/bin 21 | sudo rmdir consul-template_0.6.5_linux_amd64 22 | 23 | # consul template upstart for apache 24 | sudo cp /ops/upstart/php_consul_template.conf /etc/init/php_consul_template.conf -------------------------------------------------------------------------------- /ops/scripts/base.sh: -------------------------------------------------------------------------------- 1 | sudo apt-get -y update 2 | 3 | # install consul 4 | echo Installing dependencies... 5 | sudo apt-get install -y unzip 6 | sudo apt-get install -y curl 7 | echo Fetching Consul... 8 | cd /tmp/ 9 | wget https://dl.bintray.com/mitchellh/consul/0.5.0_linux_amd64.zip -O consul.zip 10 | echo Installing Consul... 11 | unzip consul.zip 12 | sudo chmod +x consul 13 | sudo mv consul /usr/bin/consul 14 | sudo mkdir /etc/consul.d 15 | sudo chmod -R 777 /etc/consul.d 16 | sudo chmod a+w /var/log -------------------------------------------------------------------------------- /ops/scripts/consul.sh: -------------------------------------------------------------------------------- 1 | # consul config 2 | echo Configuring Consul.... 3 | echo '{"service": {"name": "consul", "tags": ["consul", "bootstrap"]}}' \ 4 | >/etc/consul.d/bootstrap.json 5 | sudo cp /ops/upstart/consul_bootstrap.conf /etc/init/consul.conf -------------------------------------------------------------------------------- /ops/scripts/mysql.sh: -------------------------------------------------------------------------------- 1 | sudo apt-get -y update 2 | 3 | # set root password 4 | sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password password' 5 | sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password password' 6 | # Install requirements 7 | sudo apt-get install -y -qq \ 8 | mysql-server 9 | 10 | # configure mysql 11 | mysql --user=root --password=password -e "GRANT ALL ON *.* to 'apache'@'172.%.%.%' IDENTIFIED BY 'password'" 12 | 13 | # consul config 14 | sudo mv /ops/configs/consul_mysql.json /etc/consul.d/mysql.json 15 | sudo cp /ops/upstart/consul_client.conf /etc/init/consul.conf 16 | 17 | # install consul template 18 | wget https://github.com/hashicorp/consul-template/releases/download/v0.6.5/consul-template_0.6.5_linux_amd64.tar.gz 19 | tar xzf consul-template_0.6.5_linux_amd64.tar.gz 20 | sudo mv consul-template_0.6.5_linux_amd64/consul-template /usr/bin 21 | sudo rmdir consul-template_0.6.5_linux_amd64 22 | 23 | # consul template upstart for mysql 24 | sudo cp /ops/upstart/mysql_consul_template.conf /etc/init/mysql_consul_template.conf -------------------------------------------------------------------------------- /ops/templates/mysql.ctmpl: -------------------------------------------------------------------------------- 1 | # 2 | # The MySQL database server configuration file. 3 | # 4 | # You can copy this to one of: 5 | # - "/etc/mysql/my.cnf" to set global options, 6 | # - "~/.my.cnf" to set user-specific options. 7 | # 8 | # One can use all long options that the program supports. 9 | # Run program with --help to get a list of available options and with 10 | # --print-defaults to see which it would actually understand and use. 11 | # 12 | # For explanations see 13 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 14 | 15 | # This will be passed to all mysql clients 16 | # It has been reported that passwords should be enclosed with ticks/quotes 17 | # escpecially if they contain "#" chars... 18 | # Remember to edit /etc/mysql/debian.cnf when changing the socket location. 19 | [client] 20 | port = 3306 21 | socket = /var/run/mysqld/mysqld.sock 22 | 23 | # Here is entries for some specific programs 24 | # The following values assume you have at least 32M ram 25 | 26 | # This was formally known as [safe_mysqld]. Both versions are currently parsed. 27 | [mysqld_safe] 28 | socket = /var/run/mysqld/mysqld.sock 29 | nice = 0 30 | 31 | [mysqld] 32 | # 33 | # * Basic Settings 34 | # 35 | user = mysql 36 | pid-file = /var/run/mysqld/mysqld.pid 37 | socket = /var/run/mysqld/mysqld.sock 38 | port = 3306 39 | basedir = /usr 40 | datadir = /var/lib/mysql 41 | tmpdir = /tmp 42 | lc-messages-dir = /usr/share/mysql 43 | skip-external-locking 44 | # 45 | # Instead of skip-networking the default is now to listen only on 46 | # localhost which is more compatible and is not less secure.{{range service "mysql.database"}} 47 | bind-address = {{.Address}}{{end}} 48 | # 49 | # * Fine Tuning 50 | # 51 | key_buffer = 16M 52 | max_allowed_packet = 16M 53 | thread_stack = 192K 54 | thread_cache_size = 8 55 | # This replaces the startup script and checks MyISAM tables if needed 56 | # the first time they are touched 57 | myisam-recover = BACKUP 58 | #max_connections = 100 59 | #table_cache = 64 60 | #thread_concurrency = 10 61 | # 62 | # * Query Cache Configuration 63 | # 64 | query_cache_limit = 1M 65 | query_cache_size = 16M 66 | # 67 | # * Logging and Replication 68 | # 69 | # Both location gets rotated by the cronjob. 70 | # Be aware that this log type is a performance killer. 71 | # As of 5.1 you can enable the log at runtime! 72 | #general_log_file = /var/log/mysql/mysql.log 73 | #general_log = 1 74 | # 75 | # Error log - should be very few entries. 76 | # 77 | log_error = /var/log/mysql/error.log 78 | # 79 | # Here you can see queries with especially long duration 80 | #log_slow_queries = /var/log/mysql/mysql-slow.log 81 | #long_query_time = 2 82 | #log-queries-not-using-indexes 83 | # 84 | # The following can be used as easy to replay backup logs or for replication. 85 | # note: if you are setting up a replication slave, see README.Debian about 86 | # other settings you may need to change. 87 | #server-id = 1 88 | #log_bin = /var/log/mysql/mysql-bin.log 89 | expire_logs_days = 10 90 | max_binlog_size = 100M 91 | #binlog_do_db = include_database_name 92 | #binlog_ignore_db = include_database_name 93 | # 94 | # * InnoDB 95 | # 96 | # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. 97 | # Read the manual for more InnoDB related options. There are many! 98 | # 99 | # * Security Features 100 | # 101 | # Read the manual, too, if you want chroot! 102 | # chroot = /var/lib/mysql/ 103 | # 104 | # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". 105 | # 106 | # ssl-ca=/etc/mysql/cacert.pem 107 | # ssl-cert=/etc/mysql/server-cert.pem 108 | # ssl-key=/etc/mysql/server-key.pem 109 | 110 | 111 | 112 | [mysqldump] 113 | quick 114 | quote-names 115 | max_allowed_packet = 16M 116 | 117 | [mysql] 118 | #no-auto-rehash # faster start of mysql but no tab completition 119 | 120 | [isamchk] 121 | key_buffer = 16M 122 | 123 | # 124 | # * IMPORTANT: Additional settings that can override those from this file! 125 | # The files must end with '.cnf', otherwise they'll be ignored. 126 | # 127 | !includedir /etc/mysql/conf.d/ 128 | -------------------------------------------------------------------------------- /ops/templates/php.ctmpl: -------------------------------------------------------------------------------- 1 | "; 10 | ?> -------------------------------------------------------------------------------- /ops/terraform/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | access_key = "YOUR_ACCESS_KEY_HERE" 3 | secret_key = "YOUR_SECRET_KEY_HERE" 4 | region = "us-east-1" 5 | } 6 | 7 | resource "atlas_artifact" "consul" { 8 | name = "/consul" 9 | type = "aws.ami" 10 | } 11 | 12 | resource "atlas_artifact" "php" { 13 | name = "/apache-php" 14 | type = "aws.ami" 15 | } 16 | 17 | resource "atlas_artifact" "mysql" { 18 | name = "/mysql" 19 | type = "aws.ami" 20 | } 21 | 22 | resource "aws_security_group" "allow_all" { 23 | name = "allow_all" 24 | description = "Allow all inbound traffic" 25 | 26 | ingress { 27 | from_port = 0 28 | to_port = 65535 29 | protocol = "-1" 30 | cidr_blocks = ["0.0.0.0/0"] 31 | } 32 | } 33 | 34 | resource "aws_instance" "consul" { 35 | instance_type = "t2.micro" 36 | ami = "${atlas_artifact.consul.metadata_full.region-us-east-1}" 37 | security_groups = ["${aws_security_group.allow_all.name}"] 38 | 39 | # This will create 3 instances 40 | count = 3 41 | } 42 | 43 | resource "aws_instance" "php" { 44 | instance_type = "t2.micro" 45 | ami = "${atlas_artifact.php.metadata_full.region-us-east-1}" 46 | security_groups = ["${aws_security_group.allow_all.name}"] 47 | 48 | # This will create 1 instance 49 | count = 1 50 | lifecycle = { 51 | create_before_destroy = true 52 | } 53 | } 54 | 55 | resource "aws_instance" "mysql" { 56 | instance_type = "t2.micro" 57 | ami = "${atlas_artifact.mysql.metadata_full.region-us-east-1}" 58 | security_groups = ["${aws_security_group.allow_all.name}"] 59 | 60 | # This will create 1 instances 61 | count = 1 62 | lifecycle = { 63 | create_before_destroy = true 64 | } 65 | } -------------------------------------------------------------------------------- /ops/upstart/consul_bootstrap.conf: -------------------------------------------------------------------------------- 1 | description "Consul" 2 | 3 | start on vagrant-ready or runlevel [2345] 4 | stop on runlevel [!2345] 5 | 6 | respawn 7 | 8 | console log 9 | 10 | script 11 | if [ -f "/etc/service/consul" ]; then 12 | . /etc/service/consul 13 | fi 14 | 15 | # Make sure to use all our CPUs, because Consul can block a scheduler thread 16 | export GOMAXPROCS=`nproc` 17 | 18 | exec /usr/bin/consul agent \ 19 | -server \ 20 | -data-dir="/tmp/consul" \ 21 | -atlas=/infrastructure \ 22 | -atlas-join \ 23 | -atlas-token="YOUR_ATLAS_TOKEN" \ 24 | -bootstrap-expect 3 \ 25 | -config-dir="/etc/consul.d" \ 26 | ${CONSUL_FLAGS} \ 27 | >>/var/log/consul.log 2>&1 28 | end script -------------------------------------------------------------------------------- /ops/upstart/consul_client.conf: -------------------------------------------------------------------------------- 1 | description "Consul" 2 | 3 | start on vagrant-ready or runlevel [2345] 4 | stop on runlevel [!2345] 5 | 6 | respawn 7 | 8 | console log 9 | 10 | script 11 | if [ -f "/etc/service/consul" ]; then 12 | . /etc/service/consul 13 | fi 14 | 15 | # Make sure to use all our CPUs, because Consul can block a scheduler thread 16 | export GOMAXPROCS=`nproc` 17 | 18 | exec /usr/bin/consul agent \ 19 | -data-dir="/tmp/consul" \ 20 | -config-dir="/etc/consul.d" \ 21 | -atlas-token="YOUR_ATLAS_TOKEN" \ 22 | -atlas="/infrastructure" \ 23 | -atlas-join \ 24 | ${CONSUL_FLAGS} \ 25 | >>/var/log/consul.log 2>&1 26 | end script 27 | -------------------------------------------------------------------------------- /ops/upstart/mysql_consul_template.conf: -------------------------------------------------------------------------------- 1 | description "Consul" 2 | 3 | start on vagrant-ready or runlevel [2345] 4 | stop on runlevel [!2345] 5 | 6 | respawn 7 | 8 | console log 9 | 10 | script 11 | exec /usr/bin/consul-template \ 12 | -consul 127.0.0.1:8500 \ 13 | -template "/ops/templates/mysql.ctmpl:/etc/mysql/my.cnf: service mysql restart" >> /var/log/ctemplate_mysql.log 2>&1 14 | end script -------------------------------------------------------------------------------- /ops/upstart/php_consul_template.conf: -------------------------------------------------------------------------------- 1 | description "Consul" 2 | 3 | start on vagrant-ready or runlevel [2345] 4 | stop on runlevel [!2345] 5 | 6 | respawn 7 | 8 | console log 9 | 10 | script 11 | exec /usr/bin/consul-template \ 12 | -consul 127.0.0.1:8500 \ 13 | -template "/ops/templates/php.ctmpl:/var/www/html/db_connect.php: service apache2 restart" >> /var/log/ctemplate_php.log 2>&1 14 | end script --------------------------------------------------------------------------------