forked from dwmkerr/terraform-aws-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
66 lines (55 loc) · 2.8 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
infrastructure:
# Get the modules, create the infrastructure.
terraform init && terraform get && terraform apply -auto-approve
# Installs OpenShift on the cluster.
openshift:
# Add our identity for ssh, add the host key to avoid having to accept the
# the host key manually. Also add the identity of each node to the bastion.
ssh-add ~/.ssh/id_rsa
ssh-keyscan -t rsa -H $$(terraform output bastion-public_ip) >> ~/.ssh/known_hosts
ssh -A ec2-user@$$(terraform output bastion-public_ip) "ssh-keyscan -t rsa -H master.openshift.local >> ~/.ssh/known_hosts"
ssh -A ec2-user@$$(terraform output bastion-public_ip) "ssh-keyscan -t rsa -H node1.openshift.local >> ~/.ssh/known_hosts"
ssh -A ec2-user@$$(terraform output bastion-public_ip) "ssh-keyscan -t rsa -H node2.openshift.local >> ~/.ssh/known_hosts"
# Copy our inventory to the master and run the install script.
scp ./inventory.cfg ec2-user@$$(terraform output bastion-public_ip):~
cat install-from-bastion.sh | ssh -o StrictHostKeyChecking=no -A ec2-user@$$(terraform output bastion-public_ip)
# Now the installer is done, run the postinstall steps on each host.
# Note: these scripts cause a restart, so we use a hyphen to ignore the ssh
# connection termination.
- cat ./scripts/postinstall-master.sh | ssh -A ec2-user@$$(terraform output bastion-public_ip) ssh master.openshift.local
- cat ./scripts/postinstall-node.sh | ssh -A ec2-user@$$(terraform output bastion-public_ip) ssh node1.openshift.local
- cat ./scripts/postinstall-node.sh | ssh -A ec2-user@$$(terraform output bastion-public_ip) ssh node2.openshift.local
echo "Complete! Wait a minute for hosts to restart, then run 'make browse-openshift' to login."
# Destroy the infrastructure.
destroy:
terraform init && terraform destroy -auto-approve
# Open the console.
browse-openshift:
open $$(terraform output master-url)
# SSH onto the master.
ssh-bastion:
ssh -t -A ec2-user@$$(terraform output bastion-public_ip)
ssh-master:
ssh -t -A ec2-user@$$(terraform output bastion-public_ip) ssh master.openshift.local
ssh-node1:
ssh -t -A ec2-user@$$(terraform output bastion-public_ip) ssh node1.openshift.local
ssh-node2:
ssh -t -A ec2-user@$$(terraform output bastion-public_ip) ssh node2.openshift.local
# Create sample services.
sample:
oc login $$(terraform output master-url) --insecure-skip-tls-verify=true -u=admin -p=123
oc new-project sample
oc process -f ./sample/counter-service.yml | oc create -f -
# Lint the terraform files. Don't forget to provide the 'region' var, as it is
# not provided by default. Error on issues, suitable for CI.
lint:
terraform get
TF_VAR_region="us-east-1" tflint --error-with-issues
# Run the tests.
test:
echo "Simulating tests..."
# Run the CircleCI build locally.
circleci:
circleci config validate -c .circleci/config.yml
circleci build --job lint
.PHONY: sample