Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANSIBLE: 'ansible_lsb' variable is undefined for CentOS #5

Open
v1v opened this issue Nov 19, 2014 · 12 comments
Open

ANSIBLE: 'ansible_lsb' variable is undefined for CentOS #5

v1v opened this issue Nov 19, 2014 · 12 comments

Comments

@v1v
Copy link
Owner

v1v commented Nov 19, 2014

'ansible_lsb' is undefined

What about using a default value? http://docs.ansible.com/playbooks_variables.html#forcing-variables-to-be-defined

@WanderingZombie
Copy link

yum install redhat-lsb-core will make lsb_release -a available, and so ansible will then be able to set ansible_lsb.

@holms
Copy link

holms commented May 3, 2015

@WanderingZombie came here because of same error, installing redhat-lsb-core doesn't solve my issue.

@geerlingguy
Copy link

Note that you have to make sure redhat-lsb-core is installed prior to running an Ansible playbook that uses the ansible_lsb variable. This may seem obvious, but I was still seeing failures until I made sure my build process installed redhat-lsb-core prior to Ansible interaction.

@holms
Copy link

holms commented May 8, 2016

This issue can be closed I think :) That's some undocumented stuff. Would be nice to add this to ansible docs itself.

@einarc
Copy link

einarc commented May 17, 2016

@holms It is documented, I don't now if it was nine days ago but it is today:
http://docs.ansible.com/ansible/playbooks_conditionals.html

Look for this:
ansible_lsb.major_release|int

And read the note below.

@holms
Copy link

holms commented May 17, 2016

That note in there definitely haven't been there before. Been pulling my hairs and wtf'ing what's going on, when in freenode someone told me about this package. Thanks

@einarc
Copy link

einarc commented May 18, 2016

@holms Glad to hear you're pulling hairs anymore!!! Cheers!

@einarc
Copy link

einarc commented May 18, 2016

@holms Guess what:
If i run this:

- name: Get lsb_release
  yum: name=redhat-lsb-core state=present

- name: List Distro version
  debug: var="{{ansible_lsb.release|int}}"

I still get this:
fatal: [172.16.6.80]: FAILED! => {"failed": true, "msg": "'ansible_lsb' is undefined"}

If I log into the node there is the binary:

[ec2-user@ip-172-16-6-80 ~]$ lsb_release -a

LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 7.2 (Maipo)
Release:    7.2
Codename:   Maipo

There goes the hair pulling, ha!

@holms
Copy link

holms commented May 18, 2016

@einarc well like they said above, this package should be installed, before you run playbook :) That means it should be in core image of whatever cloud provider you're using, and that's actually bad.. I wonder if aws/do/gcloud has in centos core image. Maybe it's possible just to regather facts with second playbook in a row, in one file.. haven't tried yet.

@einarc
Copy link

einarc commented May 18, 2016

@holms I couldn't agree more, the core image of this RHEL7 x64 HVM AWS image is missing so many things that I have to compensate for that is taking longer than expected to do a good wordpress install. On the other hand, they offer Bitnami, but that's not what the team wants here.
Regardless, lsb_release is now installed and ansible still doesn't detect it, so there's definitively an issue that needs looking into.

@einarc
Copy link

einarc commented May 18, 2016

@holms Actually installing lsb_release does handle the issue. The problem is in the usage of this:

"{{ansible_lsb.release|int}}"

It is NOT the same as this:

ansible_lsb.release|int

The first one is a local user defined variable, the second one is an ansible environment one. Therefore it does not get defined.

@charlesnagy
Copy link

Facts are collected at the beginning of the playbook. If you install redhat-lsb-core in the very playbook than you need to reread the ansible_lsb fact.

This is fatal:

    - yum: name=redhat-lsb-core state=present

    - debug: msg={{ ansible_lsb }}

This works:

    - yum: name=redhat-lsb-core state=present

    - name: Reread ansible_lsb facts
      setup: filter=ansible_lsb*

    - debug: msg={{ ansible_lsb }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants