# Cannot source /etc/lsb-release

**URL:** <https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [September 27, 2021, 5:04pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787 "2021-09-27T17:04:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neil\_Young](https://avatars.discourse-cdn.com/v4/letter/n/a3d4f5/32.png) [@Neil\_Young](https://forum.ansible.com/u/Neil_Young)\
**Post date:** [September 27, 2021, 5:04pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/1 "2021-09-27T17:04:24Z")

</div>

Hi,

I’m banging my head trying to make this simple statement work:

- name: Get Ubuntu version definitions

ansible.builtin.shell: source /etc/lsb-release

But whatever I do I get this:

TASK [Get Ubuntu version definitions] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

fatal: [server1]: FAILED! =\> {“changed”: true, “cmd”: “source /etc/lsb-release”, “delta”: “0:00:00.002579”, “end”: “2021-09-27 17:02:32.565396”, “msg”: “non-zero return code”, “rc”: 127, “start”: “2021-09-27 17:02:32.562817”, “stderr”: “/bin/sh: 1: source: not found”, “stderr\_lines”: [“/bin/sh: 1: source: not found”], “stdout”: “”, “stdout\_lines”: }

This is most likely because I run at elevated permissions.

What can I do in order to make this work?

TIA

---

<div class="post-metadata">

**Author:** ![harry\_devine](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/harry_devine/32/5293_2.png) [@harry\_devine](https://forum.ansible.com/u/harry_devine)\
**Post date:** [September 27, 2021, 5:09pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/2 "2021-09-27T17:09:38Z")

</div>

You should use the full path to the source executable. “which source” should give you that.

Harry

---

<div class="post-metadata">

**Author:** ![Sandip\_Bhattacharya](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@Sandip\_Bhattacharya](https://forum.ansible.com/u/Sandip_Bhattacharya)\
**Post date:** [September 27, 2021, 5:11pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/3 "2021-09-27T17:11:15Z")

</div>

source is a bash built-in command. There is no executable. You can try "bash -c ‘source /etc/lsb-release’ "

HTH,  
Sandip

---

<div class="post-metadata">

**Author:** ![Neil\_Young](https://avatars.discourse-cdn.com/v4/letter/n/a3d4f5/32.png) [@Neil\_Young](https://forum.ansible.com/u/Neil_Young)\
**Post date:** [September 27, 2021, 5:14pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/4 "2021-09-27T17:14:19Z")

</div>

Exactly. which source gives nothing.

If I run the command at non-elevated level I get useful results and the environment is filled

source /etc/lsb-release

echo $DISTRIB\_CODENAME

bionic

sudo source /etc/lsb-release

[sudo] password for ubuntu:

sudo: source: command not found

So it is a matter of elevated access level, but I just don’t know how to run that at lower level…

---

<div class="post-metadata">

**Author:** ![Sandip\_Bhattacharya](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@Sandip\_Bhattacharya](https://forum.ansible.com/u/Sandip_Bhattacharya)\
**Post date:** [September 27, 2021, 5:20pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/5 "2021-09-27T17:20:05Z")

</div>

This won't work for you?

$ sudo bash -c 'source /etc/lsb-release; echo $DISTRIB\_CODENAME'  
focal

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [September 27, 2021, 5:51pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/6 "2021-09-27T17:51:33Z")

</div>

What is the purpose of this task?  
I.e. What are you trying to achieve?

---

<div class="post-metadata">

**Author:** ![Neil\_Young](https://avatars.discourse-cdn.com/v4/letter/n/a3d4f5/32.png) [@Neil\_Young](https://forum.ansible.com/u/Neil_Young)\
**Post date:** [September 27, 2021, 6:02pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/7 "2021-09-27T18:02:42Z")

</div>

Hmm. Was posting the solution already, but it doesn’t appear here…

OK, @Sandip solved it:

- name: Install Kurento Media Server - Get Ubuntu version definitions and add repository to apt  
ansible.builtin.shell: |  
source /etc/lsb-release  
tee “/etc/apt/sources.list.d/kurento.list” \>/dev/null \<\<EOF

# Kurento Media Server - Release packages

deb [arch=amd64] [http://ubuntu.openvidu.io/6.16.0](http://ubuntu.openvidu.io/6.16.0) $DISTRIB\_CODENAME kms6  
EOF  
args:  
executable: /bin/bash

Kudos to @Sandip

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [September 27, 2021, 6:13pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/8 "2021-09-27T18:13:41Z")

</div>

The information you are looking for is already available when the fact  
gathering is done.  
No need for kludgy shell pipes/source/tee/etc.  
Also there is a dedicated module for what you want. Just 3 lines  
should be enough:

- ansible.builtin.apt\_repository:  
&nbsp;&nbsp;&nbsp;&nbsp;repo: "[arch=amd64] [http://ubuntu.openvidu.io/6.16.0](http://ubuntu.openvidu.io/6.16.0) {{  
ansible\_distribution\_release }} kms6"  
&nbsp;&nbsp;&nbsp;&nbsp;filename: kurento

---

<div class="post-metadata">

**Author:** ![Neil\_Young](https://avatars.discourse-cdn.com/v4/letter/n/a3d4f5/32.png) [@Neil\_Young](https://forum.ansible.com/u/Neil_Young)\
**Post date:** [September 28, 2021, 12:33pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/9 "2021-09-28T12:33:49Z")

</div>

This does not work for me.

- ansible.builtin.apt\_repository:  
repo: “[arch=amd64] [http://ubuntu.openvidu.io/6.16.0](http://ubuntu.openvidu.io/6.16.0) {{  
ansible\_distribution\_release }} kms6”  
filename: kurento

---

<div class="post-metadata">

**Author:** ![Neil\_Young](https://avatars.discourse-cdn.com/v4/letter/n/a3d4f5/32.png) [@Neil\_Young](https://forum.ansible.com/u/Neil_Young)\
**Post date:** [September 28, 2021, 12:41pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/10 "2021-09-28T12:41:35Z")

</div>

TASK [bla] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [server1]: FAILED! =\> {“changed”: false, “msg”: “Invalid repository string: [arch=amd64] [http://ubuntu.openvidu.io/6.16.0](http://ubuntu.openvidu.io/6.16.0) bionic kms6”}

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [September 28, 2021, 12:49pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/11 "2021-09-28T12:49:02Z")

</div>

Find out what it should be and adjust the repo value

---

<div class="post-metadata">

**Author:** ![Neil\_Young](https://avatars.discourse-cdn.com/v4/letter/n/a3d4f5/32.png) [@Neil\_Young](https://forum.ansible.com/u/Neil_Young)\
**Post date:** [September 28, 2021, 12:51pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/12 "2021-09-28T12:51:12Z")

</div>

Sorry, responded on another thread. These groups are ugly.

Well, this works:

- name: Install Kurento Media Server - Get Ubuntu version definitions and add repository to apt  
ansible.builtin.shell: |  
source /etc/lsb-release  
tee “/etc/apt/sources.list.d/kurento.list” \>/dev/null \<\<EOF

# Kurento Media Server - Release packages

deb [arch=amd64] [http://ubuntu.openvidu.io/6.16.0](http://ubuntu.openvidu.io/6.16.0) $DISTRIB\_CODENAME kms6  
EOF  
args:  
executable: /bin/bash

and in the end it is just DISTRIB\_CODENAME replaced by “bionic”

---

<div class="post-metadata">

**Author:** ![Neil\_Young](https://avatars.discourse-cdn.com/v4/letter/n/a3d4f5/32.png) [@Neil\_Young](https://forum.ansible.com/u/Neil_Young)\
**Post date:** [September 28, 2021, 12:54pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/13 "2021-09-28T12:54:42Z")

</div>

Seems, {{ansible\_distribution\_release }}} rendes “Releasebionic”, which is not ok in this case

---

<div class="post-metadata">

**Author:** ![Neil\_Young](https://avatars.discourse-cdn.com/v4/letter/n/a3d4f5/32.png) [@Neil\_Young](https://forum.ansible.com/u/Neil_Young)\
**Post date:** [September 28, 2021, 12:56pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/14 "2021-09-28T12:56:59Z")

</div>

Hmm. No. Forget about my last comment. It renders “bionic”, but even if I hardcode “bionic” the error is:

fatal: [server1]: FAILED! =\> {“changed”: false, “msg”: “Invalid repository string: [arch=amd64] [http://ubuntu.openvidu.io/6.16.0](http://ubuntu.openvidu.io/6.16.0) bionic kms6”}

Anyway, disregard please. I’m fine with the other solution.

---

<div class="post-metadata">

**Author:** ![Neil\_Young](https://avatars.discourse-cdn.com/v4/letter/n/a3d4f5/32.png) [@Neil\_Young](https://forum.ansible.com/u/Neil_Young)\
**Post date:** [September 28, 2021, 12:58pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/15 "2021-09-28T12:58:21Z")

</div>

Have it. “deb” was missing in the string:

- name: Install Kurento Media Server  
ansible.builtin.apt\_repository:  
repo: “deb [arch=amd64] [http://ubuntu.openvidu.io/6.16.0](http://ubuntu.openvidu.io/6.16.0) bionic kms6”  
filename: kurento

Worx

---

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [October 5, 2021, 12:20pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/16 "2021-10-05T12:20:24Z")

</div>

I have targets who have set a user pw to expire and I want to switch the expiration off with `sudo chage -l stepuser`.

this seems to work with a task like this:

- name: switch off pw expiration for stepuser  
shell:  
cmd: chage -M -1 stepuser  
become: yes

Beind quite new to ansible I am wondering whether this is the right approach for such or anything else would be more suitable way (I can not identify any convincing paramter in the user module though)?

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [October 5, 2021, 12:35pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/17 "2021-10-05T12:35:02Z")

</div>

[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/user\_module.html#parameter-expires](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/user_module.html#parameter-expires)  
is pretty convincing to me.  
See the 3rd last example on that page:

- name: Starting at Ansible 2.6, modify user, remove expiry time  
&nbsp;&nbsp;ansible.builtin.user:  
&nbsp;&nbsp;&nbsp;&nbsp;name: james18  
&nbsp;&nbsp;&nbsp;&nbsp;expires: -1

---

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [October 5, 2021, 1:13pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/18 "2021-10-05T13:13:58Z")

</div>

thx for the feedback

> [https://docs.ansible.com/ansible/latest/collections/ansible/builtin/user\_module.html#parameter-expires](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/user_module.html#parameter-expires)  
> is pretty convincing to me.  
> See the 3rd last example on that page:
> 
> - name: Starting at Ansible 2.6, modify user, remove expiry time  
> &nbsp;&nbsp;ansible.builtin.user:  
> &nbsp;&nbsp;&nbsp;&nbsp;name: james18  
> &nbsp;&nbsp;&nbsp;&nbsp;expires: -1

that sounds right, however I seem to be unable to make it work and can't really see what the problem is [https://paste.debian.net/1214375/](https://paste.debian.net/1214375/)

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [October 5, 2021, 1:55pm UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/19 "2021-10-05T13:55:38Z")

</div>

what does your entire playbook look like? And the inventory?

I see this in the snippet:

Failed to connect to the host via ssh

that is a problem....

---

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [October 7, 2021, 11:18am UTC](https://forum.ansible.com/t/cannot-source-etc-lsb-release/35787/20 "2021-10-07T11:18:02Z")

</div>

> what does your entire playbook look like? And the inventory?
> 
> I see this in the snippet:
> 
> Failed to connect to the host via ssh

sorry, I can't exactly reconstruct what the problem was. It works now with:

> - tasks:  
> - name: switch off pw expiration  
> &nbsp;&nbsp;&nbsp;user:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name: [username]  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;expires: -1  
> &nbsp;&nbsp;&nbsp;become: yes  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
> thx and sorry for the false alarm  
> Gunnar
