-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1629 from moofish32/update_terraform_rhel7
Add support for RHEL7/Systemd in Terraform example
- Loading branch information
Showing
22 changed files
with
131 additions
and
296 deletions.
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo "Installing dependencies..." | ||
if [ -x "$(command -v apt-get)" ]; then | ||
sudo apt-get update -y | ||
sudo apt-get install -y unzip | ||
else | ||
sudo yum update -y | ||
sudo yum install -y unzip wget | ||
fi | ||
|
||
|
||
echo "Fetching Consul..." | ||
CONSUL=0.6.3 | ||
cd /tmp | ||
wget https://releases.hashicorp.com/consul/${CONSUL}/consul_${CONSUL}_linux_amd64.zip -O consul.zip | ||
|
||
echo "Installing Consul..." | ||
unzip consul.zip >/dev/null | ||
chmod +x consul | ||
sudo mv consul /usr/local/bin/consul | ||
sudo mkdir -p /opt/consul/data | ||
|
||
# Read from the file we created | ||
SERVER_COUNT=$(cat /tmp/consul-server-count | tr -d '\n') | ||
CONSUL_JOIN=$(cat /tmp/consul-server-addr | tr -d '\n') | ||
|
||
# Write the flags to a temporary file | ||
cat >/tmp/consul_flags << EOF | ||
CONSUL_FLAGS="-server -bootstrap-expect=${SERVER_COUNT} -join=${CONSUL_JOIN} -data-dir=/opt/consul/data" | ||
EOF | ||
|
||
if [ -f /tmp/upstart.conf ]; | ||
then | ||
echo "Installing Upstart service..." | ||
sudo mkdir -p /etc/consul.d | ||
sudo mkdir -p /etc/service | ||
sudo chown root:root /tmp/upstart.conf | ||
sudo mv /tmp/upstart.conf /etc/init/consul.conf | ||
sudo chmod 0644 /etc/init/consul.conf | ||
sudo mv /tmp/consul_flags /etc/service/consul | ||
sudo chmod 0644 /etc/service/consul | ||
else | ||
echo "Installing Systemd service..." | ||
sudo mkdir -p /etc/systemd/system/consul.d | ||
sudo chown root:root /tmp/consul.service | ||
sudo mv /tmp/consul.service /etc/systemd/system/consul.service | ||
sudo chmod 0644 /etc/systemd/system/consul.service | ||
sudo mv /tmp/consul_flags /etc/sysconfig/consul | ||
sudo chown root:root /etc/sysconfig/consul | ||
sudo chmod 0644 /etc/sysconfig/consul | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
sudo iptables -I INPUT -s 0/0 -p tcp --dport 8300 -j ACCEPT | ||
sudo iptables -I INPUT -s 0/0 -p tcp --dport 8301 -j ACCEPT | ||
sudo iptables -I INPUT -s 0/0 -p tcp --dport 8302 -j ACCEPT | ||
|
||
if [ -d /etc/sysconfig ]; then | ||
sudo iptables-save | sudo tee /etc/sysconfig/iptables | ||
else | ||
sudo iptables-save | sudo tee /etc/iptables.rules | ||
fi |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[Unit] | ||
Description=consul agent | ||
Requires=network-online.target | ||
After=network-online.target | ||
|
||
[Service] | ||
EnvironmentFile=-/etc/sysconfig/consul | ||
Restart=on-failure | ||
ExecStart=/usr/local/bin/consul agent $CONSUL_FLAGS -config-dir=/etc/systemd/system/consul.d | ||
ExecReload=/bin/kill -HUP $MAINPID | ||
KillSignal=SIGINT | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
2 changes: 1 addition & 1 deletion
2
terraform/aws/scripts/rhel6/upstart.conf → terraform/aws/scripts/rhel_upstart.conf
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
description "Consul agent" | ||
|
||
start on runlevel [2345] | ||
start on started network | ||
stop on runlevel [!2345] | ||
|
||
respawn | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo "Starting Consul..." | ||
if [ -x "$(command -v systemctl)" ]; then | ||
echo "using systemctl" | ||
sudo systemctl enable consul.service | ||
sudo systemctl start consul | ||
else | ||
echo "using upstart" | ||
sudo start consul | ||
fi |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.