Ansible Handbook
Search…
Ansible Galaxy

What is Ansible Galaxy?

Ansible Galaxy is a galaxy website where users can share roles and to a command-line tool for installing, creating, and managing roles.
Ansible Galaxy gives greater visibility to one of Ansible's most exciting features, such as application installation or reusable roles for server configuration. Lots of people share roles in the Ansible Galaxy.
To work with Ansible Galaxy, you need to use the ansible-galaxy command and its templates. Roles must be downloaded before they used in the playbooks. They are placed into the default directory that is /etc/ansible/roles, also depends on your version, they might placed in your current user home directory.
If roles are stored in /etc/ansible/roles you have to have sudo access.
Currently we don't have any roles in default place:
1
[[email protected] demo-galaxy]$ ls /etc/ansible/roles/
Copied!

Search on Galaxy

ansible-galaxy search searches for roles on the Ansible Galaxy server. Lets search for apache for example:
1
[[email protected] demo-galaxy]$ ansible-galaxy search apache
2
​
3
Found 3237 roles matching your search. Showing first 1000.
4
​
5
Name Description
6
---- -----------
7
0utsider.ansible_zabbix_agent Installing and maintaining zabbix-agent for RedHat/Debian/Ubuntu.
8
0x0i.elasticsearch Elasticsearch, a real-time distributed search and analytics engine
9
0x0i.kafka Kafka, a distributed and fault tolerant stream-processing platform
10
0x0i.systemd Systemd, a system and service manager for Linux operating systems
11
1it.docker-run Ansible role to build and run docker containers docker-compose like style
12
1it.riak Installs and configures Riak KV and TS, a distributed, highly available NoSQL and
13
1nfinitum.php PHP installation role.
14
4linuxdevops.web-server Instalacao e Configuracao do servidor Apache
15
5KYDEV0P5.common Common Utilities and package installation for Linux
16
5KYDEV0P5.skydevops-java Installs and configures Oracle Java 1.8.x
17
5KYDEV0P5.skydevops-maven Install and configure Apache Mvaen 3.x.x
18
...
Copied!

Download from Galaxy

Use the ansible-galaxy install command to download roles from the Galaxy server​
1
[[email protected] demo-galaxy]$ ansible-galaxy install geerlingguy.apache geerlingguy.mysql
2
- downloading role 'apache', owned by geerlingguy
3
- downloading role from https://github.com/geerlingguy/ansible-role-apache/archive/3.1.4.tar.gz
4
- extracting geerlingguy.apache to /home/user1/.ansible/roles/geerlingguy.apache
5
- geerlingguy.apache (3.1.4) was installed successfully
6
- downloading role 'mysql', owned by geerlingguy
7
- downloading role from https://github.com/geerlingguy/ansible-role-mysql/archive/3.3.2.tar.gz
8
- extracting geerlingguy.mysql to /home/user1/.ansible/roles/geerlingguy.mysql
9
- geerlingguy.mysql (3.3.2) was installed successfully
Copied!
Lets take look at what it has downloaded:
1
[[email protected] demo-galaxy]$
2
[[email protected] demo-galaxy]$ ls /home/user1/.ansible/roles/
3
geerlingguy.apache geerlingguy.mysql
4
[[email protected] demo-galaxy]$
5
[[email protected] demo-galaxy]$ cd /home/user1/.ansible/roles/
7
[[email protected] roles]$ cd geerlingguy.apache/
8
[[email protected] geerlingguy.apache]$ ls
9
defaults handlers LICENSE meta molecule README.md tasks templates vars
10
[[email protected] demo-galaxy]$
11
[[email protected] geerlingguy.apache]$ cd ~/demo-galaxy/
12
[[email protected] demo-galaxy]$
Copied!
For using downloaded role, we have to create a simple playbook:
1
---
2
#Sample playbook for galaxy and roles galaxy-playbook.yaml
3
​
4
- hosts: all
5
become: yes
6
roles:
7
​
8
- geerlingguy.apache
9
- geerlingguy.mysql
Copied!
and like always run it:
1
[[email protected] demo-galaxy]$ ansible-playbook galaxy-playbook.yaml
2
​
3
PLAY [all] *************************************************************************************************************************************
4
​
5
TASK [Gathering Facts] *************************************************************************************************************************
6
ok: [centos]
7
ok: [ubuntu]
8
​
9
TASK [geerlingguy.apache : Include OS-specific variables.] *************************************************************************************
10
ok: [ubuntu]
11
ok: [centos]
12
​
13
TASK [geerlingguy.apache : Include variables for Amazon Linux.] ********************************************************************************
14
skipping: [ubuntu]
15
skipping: [centos]
16
​
17
TASK [geerlingguy.apache : Define apache_packages.] ********************************************************************************************
18
ok: [ubuntu]
19
ok: [centos]
20
​
21
TASK [geerlingguy.apache : include_tasks] ******************************************************************************************************
22
included: /home/user1/.ansible/roles/geerlingguy.apache/tasks/setup-Debian.yml for ubuntu
23
included: /home/user1/.ansible/roles/geerlingguy.apache/tasks/setup-RedHat.yml for centos
24
​
25
TASK [geerlingguy.apache : Update apt cache.] **************************************************************************************************
26
changed: [ubuntu]
27
​
28
TASK [geerlingguy.apache : Ensure Apache is installed on Debian.] ******************************************************************************
29
ok: [ubuntu]
30
​
31
TASK [geerlingguy.apache : Ensure Apache is installed on RHEL.] ********************************************************************************
32
changed: [centos]
33
​
34
TASK [geerlingguy.apache : Get installed version of Apache.] ***********************************************************************************
35
ok: [centos]
36
ok: [ubuntu]
37
​
38
TASK [geerlingguy.apache : Create apache_version variable.] ************************************************************************************
39
ok: [ubuntu]
40
ok: [centos]
41
​
42
TASK [geerlingguy.apache : Include Apache 2.2 variables.] **************************************************************************************
43
skipping: [ubuntu]
44
skipping: [centos]
45
​
46
TASK [geerlingguy.apache : Include Apache 2.4 variables.] **************************************************************************************
47
ok: [ubuntu]
48
ok: [centos]
49
​
50
TASK [geerlingguy.apache : Configure Apache.] **************************************************************************************************
51
included: /home/user1/.ansible/roles/geerlingguy.apache/tasks/configure-Debian.yml for ubuntu
52
included: /home/user1/.ansible/roles/geerlingguy.apache/tasks/configure-RedHat.yml for centos
53
​
54
TASK [geerlingguy.apache : Configure Apache.] **************************************************************************************************
55
ok: [ubuntu] => (item={u'regexp': u'^Listen ', u'line': u'Listen 80'})
56
​
57
TASK [geerlingguy.apache : Enable Apache mods.] ************************************************************************************************
58
changed: [ubuntu] => (item=rewrite.load)
59
changed: [ubuntu] => (item=ssl.load)
60
​
61
TASK [geerlingguy.apache : Disable Apache mods.] ***********************************************************************************************
62
​
63
TASK [geerlingguy.apache : Check whether certificates defined in vhosts exist.] ****************************************************************
64
​
65
TASK [geerlingguy.apache : Add apache vhosts configuration.] ***********************************************************************************
66
changed: [ubuntu]
67
​
68
TASK [geerlingguy.apache : Add vhost symlink in sites-enabled.] ********************************************************************************
69
changed: [ubuntu]
70
​
71
TASK [geerlingguy.apache : Remove default vhost in sites-enabled.] *****************************************************************************
72
skipping: [ubuntu]
73
​
74
TASK [geerlingguy.apache : Configure Apache.] **************************************************************************************************
75
ok: [centos] => (item={u'regexp': u'^Listen ', u'line': u'Listen 80'})
76
​
77
TASK [geerlingguy.apache : Check whether certificates defined in vhosts exist.] ****************************************************************
78
​
79
TASK [geerlingguy.apache : Add apache vhosts configuration.] ***********************************************************************************
80
changed: [centos]
81
​
82
TASK [geerlingguy.apache : Check if localhost cert exists (RHEL 8 and later).] *****************************************************************
83
skipping: [centos]
84
​
85
TASK [geerlingguy.apache : Ensure httpd certs are installed (RHEL 8 and later).] ***************************************************************
86
skipping: [centos]
87
​
88
TASK [geerlingguy.apache : Ensure Apache has selected state and enabled on boot.] **************************************************************
89
ok: [centos]
90
ok: [ubuntu]
91
​
92
TASK [geerlingguy.mysql : include_tasks] *******************************************************************************************************
93
included: /home/user1/.ansible/roles/geerlingguy.mysql/tasks/variables.yml for ubuntu, centos
94
​
95
TASK [geerlingguy.mysql : Include OS-specific variables.] **************************************************************************************
96
ok: [ubuntu] => (item=/home/user1/.ansible/roles/geerlingguy.mysql/vars/Debian.yml)
97
ok: [centos] => (item=/home/user1/.ansible/roles/geerlingguy.mysql/vars/RedHat-7.yml)
98
​
99
TASK [geerlingguy.mysql : Define mysql_packages.] **********************************************************************************************
100
ok: [ubuntu]
101
ok: [centos]
102
​
103
TASK [geerlingguy.mysql : Define mysql_daemon.] ************************************************************************************************
104
ok: [ubuntu]
105
ok: [centos]
106
​
107
TASK [geerlingguy.mysql : Define mysql_slow_query_log_file.] ***********************************************************************************
108
ok: [ubuntu]
109
ok: [centos]
110
​
111
TASK [geerlingguy.mysql : Define mysql_log_error.] *********************************************************************************************
112
ok: [ubuntu]
113
ok: [centos]
114
​
115
TASK [geerlingguy.mysql : Define mysql_syslog_tag.] ********************************************************************************************
116
ok: [ubuntu]
117
ok: [centos]
118
​
119
TASK [geerlingguy.mysql : Define mysql_pid_file.] **********************************************************************************************
120
ok: [ubuntu]
121
ok: [centos]
122
​
123
TASK [geerlingguy.mysql : Define mysql_config_file.] *******************************************************************************************
124
ok: [ubuntu]
125
ok: [centos]
126
​
127
TASK [geerlingguy.mysql : Define mysql_config_include_dir.] ************************************************************************************
128
ok: [ubuntu]
129
ok: [centos]
130
​
131
TASK [geerlingguy.mysql : Define mysql_socket.] ************************************************************************************************
132
ok: [ubuntu]
133
ok: [centos]
134
​
135
TASK [geerlingguy.mysql : Define mysql_supports_innodb_large_prefix.] **************************************************************************
136
ok: [ubuntu]
137
ok: [centos]
138
​
139
TASK [geerlingguy.mysql : include_tasks] *******************************************************************************************************
140
skipping: [ubuntu]
141
included: /home/user1/.ansible/roles/geerlingguy.mysql/tasks/setup-RedHat.yml for centos
142
​
143
TASK [geerlingguy.mysql : Ensure MySQL packages are installed.] ********************************************************************************
144
changed: [centos]
145
​
146
TASK [geerlingguy.mysql : include_tasks] *******************************************************************************************************
147
skipping: [centos]
148
included: /home/user1/.ansible/roles/geerlingguy.mysql/tasks/setup-Debian.yml for ubuntu
149
​
150
TASK [geerlingguy.mysql : Check if MySQL is already installed.] ********************************************************************************
151
ok: [ubuntu]
152
​
153
TASK [geerlingguy.mysql : Update apt cache if MySQL is not yet installed.] *********************************************************************
154
changed: [ubuntu]
155
​
156
TASK [geerlingguy.mysql : Ensure MySQL Python libraries are installed.] ************************************************************************
157
changed: [ubuntu]
158
​
159
TASK [geerlingguy.mysql : Ensure MySQL packages are installed.] ********************************************************************************
160
changed: [ubuntu]
161
​
162
TASK [geerlingguy.mysql : Ensure MySQL is stopped after initial install.] **********************************************************************
163
changed: [ubuntu]
164
​
165
TASK [geerlingguy.mysql : Delete innodb log files created by apt package after initial install.] ***********************************************
166
changed: [ubuntu] => (item=ib_logfile0)
167
changed: [ubuntu] => (item=ib_logfile1)
168
​
169
TASK [geerlingguy.mysql : include_tasks] *******************************************************************************************************
170
skipping: [ubuntu]
171
skipping: [centos]
172
​
173
TASK [geerlingguy.mysql : Check if MySQL packages were installed.] *****************************************************************************
174
ok: [ubuntu]
175
ok: [centos]
176
​
177
TASK [geerlingguy.mysql : include_tasks] *******************************************************************************************************
178
included: /home/user1/.ansible/roles/geerlingguy.mysql/tasks/configure.yml for ubuntu, centos
179
​
180
TASK [geerlingguy.mysql : Get MySQL version.] **************************************************************************************************
181
ok: [ubuntu]
182
ok: [centos]
183
​
184
TASK [geerlingguy.mysql : Copy my.cnf global MySQL configuration.] *****************************************************************************
185
changed: [ubuntu]
186
changed: [centos]
187
​
188
TASK [geerlingguy.mysql : Verify mysql include directory exists.] ******************************************************************************
189
skipping: [ubuntu]
190
skipping: [centos]
191
​
192
TASK [geerlingguy.mysql : Copy my.cnf override files into include directory.] ******************************************************************
193
​
194
TASK [geerlingguy.mysql : Create slow query log file (if configured).] *************************************************************************
195
skipping: [ubuntu]
196
skipping: [centos]
197
​
198
TASK [geerlingguy.mysql : Create datadir if it does not exist] *********************************************************************************
199
changed: [ubuntu]
200
ok: [centos]
201
​
202
TASK [geerlingguy.mysql : Set ownership on slow query log file (if configured).] ***************************************************************
203
skipping: [ubuntu]
204
skipping: [centos]
205
​
206
TASK [geerlingguy.mysql : Create error log file (if configured).] ******************************************************************************
207
skipping: [ubuntu]
208
skipping: [centos]
209
​
210
TASK [geerlingguy.mysql : Set ownership on error log file (if configured).] ********************************************************************
211
skipping: [ubuntu]
212
skipping: [centos]
213
​
214
TASK [geerlingguy.mysql : Ensure MySQL is started and enabled on boot.] ************************************************************************
215
changed: [ubuntu]
216
changed: [centos]
217
​
218
TASK [geerlingguy.mysql : include_tasks] *******************************************************************************************************
219
included: /home/user1/.ansible/roles/geerlingguy.mysql/tasks/secure-installation.yml for ubuntu, centos
220
​
221
TASK [geerlingguy.mysql : Ensure default user is present.] *************************************************************************************
222
skipping: [ubuntu]
223
skipping: [centos]
224
​
225
TASK [geerlingguy.mysql : Copy user-my.cnf file with password credentials.] ********************************************************************
226
skipping: [ubuntu]
227
skipping: [centos]
228
​
229
TASK [geerlingguy.mysql : Disallow root login remotely] ****************************************************************************************
230
ok: [ubuntu] => (item=DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1'))
231
ok: [centos] => (item=DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1'))
232
​
233
TASK [geerlingguy.mysql : Get list of hosts for the root user.] ********************************************************************************
234
ok: [ubuntu]
235
ok: [centos]
236
​
237
TASK [geerlingguy.mysql : Update MySQL root password for localhost root account (5.7.x).] ******************************************************
238
skipping: [centos] => (item=127.0.0.1)
239
skipping: [centos] => (item=::1)
240
skipping: [centos] => (item=localhost)
241
changed: [ubuntu] => (item=localhost)
242
​
243
TASK [geerlingguy.mysql : Update MySQL root password for localhost root account (< 5.7.x).] ****************************************************
244
skipping: [ubuntu] => (item=localhost)
245
changed: [centos] => (item=127.0.0.1)
246
changed: [centos] => (item=::1)
247
changed: [centos] => (item=localhost)
248
​
249
TASK [geerlingguy.mysql : Copy .my.cnf file with root password credentials.] *******************************************************************
250
changed: [ubuntu]
251
changed: [centos]
252
​
253
TASK [geerlingguy.mysql : Get list of hosts for the anonymous user.] ***************************************************************************
254
ok: [ubuntu]
255
ok: [centos]
256
​
257
TASK [geerlingguy.mysql : Remove anonymous MySQL users.] ***************************************************************************************
258
changed: [centos] => (item=centos.example.com)
259
changed: [centos] => (item=localhost)
260
[WARNING]: Module did not set no_log for update_password
261
​
262
TASK [geerlingguy.mysql : Remove MySQL test database.] *****************************************************************************************
263
changed: [centos]
264
ok: [ubuntu]
265
​
266
TASK [geerlingguy.mysql : include_tasks] *******************************************************************************************************
267
included: /home/user1/.ansible/roles/geerlingguy.mysql/tasks/databases.yml for ubuntu, centos
268
​
269
TASK [geerlingguy.mysql : Ensure MySQL databases are present.] *********************************************************************************
270
​
271
TASK [geerlingguy.mysql : include_tasks] *******************************************************************************************************
272
included: /home/user1/.ansible/roles/geerlingguy.mysql/tasks/users.yml for ubuntu, centos
273
​
274
TASK [geerlingguy.mysql : Ensure MySQL users are present.] *************************************************************************************
275
skipping: [ubuntu]
276
skipping: [centos]
277
​
278
TASK [geerlingguy.mysql : include_tasks] *******************************************************************************************************
279
included: /home/user1/.ansible/roles/geerlingguy.mysql/tasks/replication.yml for ubuntu, centos
280
​
281
TASK [geerlingguy.mysql : Ensure replication user exists on master.] ***************************************************************************
282
skipping: [ubuntu]
283
skipping: [centos]
284
​
285
TASK [geerlingguy.mysql : Check slave replication status.] *************************************************************************************
286
skipping: [ubuntu]
287
skipping: [centos]
288
​
289
TASK [geerlingguy.mysql : Check master replication status.] ************************************************************************************
290
skipping: [ubuntu]
291
skipping: [centos]
292
​
293
TASK [geerlingguy.mysql : Configure replication on the slave.] *********************************************************************************
294
skipping: [ubuntu]
295
skipping: [centos]
296
​
297
TASK [geerlingguy.mysql : Start replication.] **************************************************************************************************
298
skipping: [ubuntu]
299
skipping: [centos]
300
​
301
RUNNING HANDLER [geerlingguy.apache : restart apache] ******************************************************************************************
302
changed: [ubuntu]
303
changed: [centos]
304
​
305
RUNNING HANDLER [geerlingguy.mysql : restart mysql] ********************************************************************************************
306
[WARNING]: Ignoring "sleep" as it is not used in "systemd"
307
[WARNING]: Ignoring "sleep" as it is not used in "systemd"
308
changed: [ubuntu]
309
changed: [centos]
310
​
311
PLAY RECAP *************************************************************************************************************************************
312
centos : ok=45 changed=11 unreachable=0 failed=0 skipped=23 rescued=0 ignored=0
313
ubuntu : ok=52 changed=16 unreachable=0 failed=0 skipped=24 rescued=0 ignored=0
Copied!
and it runs tons of tasks.

Upload to Galaxy

To upload a role to ansibel galaxy, first you have to upload it to your github project and next log in to your ansible galaxy account and pull that, That's all.
.
.
.
.
​