how to use ansible galaxy roles

257 views
Skip to first unread message

jithendra myla

unread,
Feb 2, 2017, 12:35:09 PM2/2/17
to Ansible Project
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






Stankovic, Marko

unread,
Feb 3, 2017, 4:29:51 AM2/3/17
to Ansible Project
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
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

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.

jithendra myla

unread,
Feb 3, 2017, 4:18:41 PM2/3/17
to Ansible Project
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 ?

jithendra myla

unread,
Feb 3, 2017, 4:28:09 PM2/3/17
to Ansible Project
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


On Thursday, February 2, 2017 at 12:35:09 PM UTC-5, jithendra myla wrote:

Dick Davies

unread,
Feb 4, 2017, 11:05:44 AM2/4/17
to ansible list
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.
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/26c17e1a-4598-4419-9014-9296662c7f1e%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages