# how to use ansible galaxy roles

**URL:** <https://forum.ansible.com/t/how-to-use-ansible-galaxy-roles/23623>\
**Category:** Ansible Project\
**Tags:** galaxy-ng\
**Created:** [February 2, 2017, 5:35pm UTC](https://forum.ansible.com/t/how-to-use-ansible-galaxy-roles/23623 "2017-02-02T17:35:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jithendra\_myla](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jithendra\_myla](https://forum.ansible.com/u/jithendra_myla)\
**Post date:** [February 2, 2017, 5:35pm UTC](https://forum.ansible.com/t/how-to-use-ansible-galaxy-roles/23623/1 "2017-02-02T17:35:09Z")

</div>

Hello Sir/madam,

I downloaded the ansible galaxy roles using `ansible-galaxy install bennojoy.mysql from https://galaxy.ansible.com/bennojoy/mysql/ ,`  
`when i run it as below i get below error`

`[ansible@centos1 playbooks]$ pwd`  
`/home/ansible/ansible/playbooks`  
`[ansible@centos1 playbooks]$ ls -ltr`  
`-rw-rw-r--. 1 ansible ansible 148 Feb 2 12:14 mysql_server.yml`  
`drwxrwxr-x. 8 ansible ansible 102 Feb 2 12:19 mysql`  
`-rw-rw-r--. 1 ansible ansible 10 Feb 2 12:20 mysql_server.retry`  
`[ansible@centos1 playbooks]$ ansible-playbook mysql_server.yml -C`

`PLAY [localhost] *************************************************************** `

`TASK [setup] ******************************************************************* `  
`ok: [localhost]`

`TASK [mysql : Add the OS specific variables] *********************************** `  
`ok: [localhost]`

`TASK [mysql : Install the mysql packages in Redhat derivatives] **************** `  
`failed: [localhost] (item=[u'mysql_pkgs']) => {"changed": false, "failed": true, "item": ["mysql_pkgs"], "msg": "No package matching 'mysql_pkgs' found available, installed or updated", "rc": 126, "results": ["No package matching 'mysql_pkgs' found available, installed or updated"]}`  
`to retry, use: --limit @/home/ansible/ansible/playbooks/mysql_server.retry`

`PLAY RECAP ********************************************************************* `  
`localhost : ok=2 changed=0 unreachable=0 failed=1`

`[ansible@centos1 playbooks]$`  
`[ansible@centos1 playbooks]$ cat mysql_server.yml`  
`---`  
`- hosts: localhost`  
`roles:`  
`- {role: mysql, mysql_db: [{name: sql_first_db}], mysql_users: [{name: sql1, pass: papa123, priv: "*.*:ALL"}] }`  
`[ansible@centos1 playbooks]$`

`[ansible@centos1 playbooks]$ cat mysql/vars/RedHat.yml`  
`---`  
`mysql_pkgs:`  
`- libselinux-python`  
`- mysql-server`  
`- MySQL-python`

`mysql_service: mysqld`

`mysql_conf_dir: "/etc/"`  
`[ansible@centos1 playbooks]$`

`not sure defining a variable like above works, Can you please help me out`

`Thank you very much for helping me`

`-Jithendra Myla`

---

<div class="post-metadata">

**Author:** ![Stankovic\_Marko](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@Stankovic\_Marko](https://forum.ansible.com/u/Stankovic_Marko)\
**Post date:** [February 3, 2017, 9:29am UTC](https://forum.ansible.com/t/how-to-use-ansible-galaxy-roles/23623/2 "2017-02-03T09:29:44Z")

</div>

Hi,

The problem is caused by using "bare" variable in "with\_items" in line 7 and few more lines below:  
[https://github.com/bennojoy/mysql/blob/master/tasks/main.yml#L7](https://github.com/bennojoy/mysql/blob/master/tasks/main.yml#L7)  
This file is last updated on Nov 4, 2014 when this was allowed, but it's not anymore:  
[https://github.com/ansible/ansible/blob/devel/CHANGELOG.md#removed-deprecated](https://github.com/ansible/ansible/blob/devel/CHANGELOG.md#removed-deprecated)

Try fixing it locally (and/or submit a PR/issue at GitHub) or search for another similar role.

Cheers,  
Marko  
CONFIDENTIALITY NOTICE: This message is the property of International Game Technology PLC and/or its subsidiaries and may contain proprietary, confidential or trade secret information. This message is intended solely for the use of the addressee. If you are not the intended recipient and have received this message in error, please delete this message from your system. Any unauthorized reading, distribution, copying, or other use of this message or its attachments is strictly prohibited.

---

<div class="post-metadata">

**Author:** ![jithendra\_myla](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jithendra\_myla](https://forum.ansible.com/u/jithendra_myla)\
**Post date:** [February 3, 2017, 9:18pm UTC](https://forum.ansible.com/t/how-to-use-ansible-galaxy-roles/23623/3 "2017-02-03T21:18:40Z")

</div>

Hi Marko,

Thank you for taking time to help me out, i updated the with\_items locally, like below

- name: Install the mysql packages in Redhat derivatives  
yum: name={{ item }} state=installed  
with\_items:
- python-selinux
- mysql-server
- python-mysqldb

when: ansible\_os\_family == ‘RedHat’

now i am getting  
[ansible@centos1 playbooks]$ ansible-playbook mysql\_server.yml -C

PLAY [localhost] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [mysql : Add the OS specific variables] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [mysql : Install the mysql packages in Redhat derivatives] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [localhost] (item=[u’python-selinux’, u’mysql-server’, u’python-mysqldb’]) =\> {“changed”: false, “failed”: true, “item”: [“python-selinux”, “mysql-server”, “python-mysqldb”], “msg”: “No package matching ‘python-selinux’ found available, installed or updated”, “rc”: 126, “results”: [“No package matching ‘python-selinux’ found available, installed or updated”]}  
to retry, use: --limit @/home/ansible/ansible/playbooks/mysql\_server.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=2 changed=0 unreachable=0 failed=1

[ansible@centos1 playbooks]$

Do i need to add any repo for yum ?

---

<div class="post-metadata">

**Author:** ![jithendra\_myla](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jithendra\_myla](https://forum.ansible.com/u/jithendra_myla)\
**Post date:** [February 3, 2017, 9:28pm UTC](https://forum.ansible.com/t/how-to-use-ansible-galaxy-roles/23623/4 "2017-02-03T21:28:09Z")

</div>

Hi Marko,

I updated with correct REDHAT packages, Sorry for confusion, now i get below error

[ansible@centos1 playbooks]$ ansible-playbook mysql\_server.yml -C

PLAY [localhost] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [mysql : Add the OS specific variables] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [mysql : Install the mysql packages in Redhat derivatives] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [localhost] (item=[u’libselinux-python’, u’mysql-server’, u’MySQL-python’]) =\> {“changed”: false, “failed”: true, “item”: [“libselinux-python”, “mysql-server”, “MySQL-python”], “msg”: “No package matching ‘mysql-server’ found available, installed or updated”, “rc”: 126, “results”: [“libselinux-python-2.5-6.el7.x86\_64 providing libselinux-python is already installed”, “No package matching ‘mysql-server’ found available, installed or updated”]}  
to retry, use: --limit @/home/ansible/ansible/playbooks/mysql\_server.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=2 changed=0 unreachable=0 failed=1

[ansible@centos1 playbooks]$

below are the redhat packages

- libselinux-python
- mysql-server
- MySQL-python

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [February 4, 2017, 4:05pm UTC](https://forum.ansible.com/t/how-to-use-ansible-galaxy-roles/23623/5 "2017-02-04T16:05:34Z")

</div>

Yum isn't seeing the 'mysql-server' package in any of its configured repos.  
That's the right name for EL6 redhat/centos, maybe you're missing one of the  
base repos?

Get that working first before you ask Ansible to install it, and  
things will be ok.
