-
Notifications
You must be signed in to change notification settings - Fork 0
/
apache-openjdk8-linux.yml
75 lines (69 loc) · 2.19 KB
/
apache-openjdk8-linux.yml
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
67
68
69
70
71
72
73
74
75
name: Apache Web Server and Java 8 OpenJDK
description: Install the latest Apache Web Server and Java 8 OpenJDK.
schemaVersion: 1.0
phases:
- name: build
steps:
- name: InstallOpenJDK
action: ExecuteBash
inputs:
commands:
- sudo yum install java-1.8.0-openjdk -y
- name: InstallApache
action: ExecuteBash
inputs:
commands:
- sudo yum install httpd -y
- sudo systemctl start httpd
- sudo systemctl enable httpd
- sudo usermod -a -G apache ec2-user
- name: DownloadIndexFile
action: S3Download
inputs:
- source: s3://10ambatch/index.html
destination: /var/www/html/index.html
- name: ChangeIndexFilePermission
action: ExecuteBash
onFailure: Continue
inputs:
commands:
- "chmod 755 {{ build.DownloadIndexFile.inputs[0].destination }}"
- name: validate
steps:
- name: ValidateApacheService
action: ExecuteBash
inputs:
commands:
- |
CUR_STATE=$(systemctl is-active httpd)
if [[ $CUR_STATE == "active" ]]; then
echo "Apache service is active."
exit 0
else
echo "Apache service is not active. State '$CUR_STATE'. Failing."
exit 1
fi
- name: ValidateApacheCommandExists
action: ExecuteBash
inputs:
commands:
- |
if type -P httpd &>/dev/null; then
echo "Apache command exists."
exit 0
else
echo "Apache command does not exist. Failing."
exit 1
fi
- name: ValidateApacheGroupMembership
action: ExecuteBash
inputs:
commands:
- |
if groups ec2-user | grep &>/dev/null 'apache'; then
echo "The 'ec2-user' is a member of the 'apache' group."
exit 0
else
echo "The 'ec2-user' is not a member of the 'apache' group. Failing."
exit 1
fi