-
Notifications
You must be signed in to change notification settings - Fork 1
/
RHEL7x_Install-Hubot-playbook.yml
146 lines (117 loc) · 4.67 KB
/
RHEL7x_Install-Hubot-playbook.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
---
################################################################################
# description: Installs a basic Hubot kit on RHEL7x
# usage: ansible-playbook RHEL7x_Install-Hubot-playbook.yml --extra-vars 'HostOrGroup=YourServerOrGroupNameGoesHere'
# or: ansible-playbook RHEL7x_Install-Hubot-playbook.yml --extra-vars 'HostOrGroup=YourServerOrGroupNameGoesHere CLC_V2_API_USERNAME=YourCenturyLinkCloudControlUsername CLC_V2_API_PASSWD=YourCenturyLinkCloudControlPassword HUBOT_SLACK_BOTNAME=YourHubotNameGoesHere HUBOT_SLACK_TOKEN=YourHubotSlackAPITokenKeyGoesHere'
# author: Ernest G. Wilson II <[email protected]> (https://github.com/ernestgwilsonii)
# license: MIT
################################################################################
# Ansible Playbook options
# REF: http://docs.ansible.com/ansible/playbooks.html
#####################################################
- name: Install a basic Hubot kit on RHEL7x
hosts: "{{ HostOrGroup|default ('FATAL ERROR --> HostOrGroup NOT SET! You must specify either a Host or a Group name!') }}"
serial: "100%"
gather_facts: False
tasks:
# Create and manage user accounts
# REF: http://docs.ansible.com/ansible/user_module.html
#######################################################
- name: Add user chatops to the OS so hubot does not run as root
user:
name=chatops
comment="Hubot"
group=wheel
# Use the file module to create a directory and symbolic links if they don't exist
# REF: http://docs.ansible.com/ansible/file_module.html
##################################################################################
# /opt/chatops
- name: Create directory /opt/chatops if it does not exist - mkdir -p /opt/chatops
file:
path=/opt/chatops
state=directory
mode=0755
owner=chatops
group=wheel
recurse=yes
# /opt/chatops/scripts
- name: Create directory /opt/chatops/scripts if it does not exist - mkdir -p /opt/chatops/scripts
file:
path=/opt/chatops/scripts
state=directory
mode=0755
owner=chatops
group=wheel
recurse=yes
# Use the template module to populate files with data
# REF: http://docs.ansible.com/ansible/template_module.html
###########################################################
# /etc/systemd/system/chatops.service
- name: Fill in the variables and copy templates/Hubot/chatops.service.j2 to remote /etc/systemd/system/chatops.service
template:
src=templates/Hubot/chatops.service.j2
dest=/etc/systemd/system/chatops.service
owner=root
group=wheel
mode=0755
# Use the copy module to copy various files into place
# REF: http://docs.ansible.com/ansible/copy_module.html
#######################################################
# /opt/chatops/package.json
- name: Copy files/Hubot/package.json to remote /opt/chatops/package.json
copy:
src=files/Hubot/package.json
dest=/opt/chatops/package.json
owner=chatops
group=wheel
mode=0644
# /opt/chatops/external-scripts.json
- name: Copy files/Hubot/external-scripts.json to remote /opt/chatops/external-scripts.json
copy:
src=files/Hubot/external-scripts.json
dest=/opt/chatops/external-scripts.json
owner=chatops
group=wheel
mode=0644
# /opt/chatops/scripts/hubot-clc-diags.js
- name: Copy files/Hubot/hubot-clc-diags.js to remote /opt/chatops/scripts/hubot-clc-diags.js
copy:
src=files/Hubot/hubot-clc-diags.js
dest=/opt/chatops/scripts/hubot-clc-diags.js
owner=chatops
group=wheel
mode=0755
# Use npm to install and manage Node.js packages
# REF: http://docs.ansible.com/ansible/npm_module.html
######################################################
- name: Run npm install in /opt/chatops
npm:
path=/opt/chatops
state=latest
production=yes
global=no
# Set attributes of files
# REF: http://docs.ansible.com/ansible/file_module.html
#######################################################
# /opt/chatops/chatops.service
- name: Create a symbolic link - ln -s /etc/systemd/system/chatops.service /opt/chatops/chatops.service
file:
src=/etc/systemd/system/chatops.service
dest=/opt/chatops/chatops.service
state=link
owner=root
group=wheel
- name: Set directory permisions on /opt/chatops
file:
path=/opt/chatops
state=directory
owner=chatops
group=wheel
recurse=yes
# Enable but do not start chatops.service
# REF: http://docs.ansible.com/ansible/service_module.html
##########################################################
- name: Enable but do not start the chatops.service service
service:
name=chatops.service
enabled=yes