# dnf - install postgresql fom postgresql.org yum repos

**URL:** <https://forum.ansible.com/t/dnf-install-postgresql-fom-postgresql-org-yum-repos/36463>\
**Category:** Ansible Project\
**Tags:** rhel\
**Created:** [March 20, 2022, 9:30am UTC](https://forum.ansible.com/t/dnf-install-postgresql-fom-postgresql-org-yum-repos/36463 "2022-03-20T09:30:26Z")\
**Posts on this page:** 2\
**Page:** 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:** [March 20, 2022, 9:30am UTC](https://forum.ansible.com/t/dnf-install-postgresql-fom-postgresql-org-yum-repos/36463/1 "2022-03-20T09:30:26Z")

</div>

I want to install PostgreSQL & barman with Ansible from the [PostgreSQL.org](http://PostgreSQL.org) repositories on an almalinux lxd container.

> - name: “install PostgreSQL-14 & barman @rhel via [postgresql.org](http://postgresql.org) repos”  
> hosts: barman-220320  
> tasks:
> - name: “install postgresql-14 & barman”  
> dnf:  
> name: “{{ item }}”  
> enablerepo: [https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86\_64/pgdg-redhat-repo-latest.noarch.rpm](https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm)  
> state: latest  
> loop:
> - postgresql14-server
> - barman  
> become: true

as none of the 2 package can be installed it seems my enablerepo is not working though:

> failed: [barman-220320] (item=postgresql14-server) =\> changed=false  
> ansible\_loop\_var: item  
> failures:
> 
> - **No package postgresql14-server available**.  
> item: postgresql14-server  
> msg: Failed to install some of the specified packages  
> rc: 1  
> results:   
> failed: [barman-220320] (item=barman) =\> changed=false  
> ansible\_loop\_var: item  
> failures:
> - **No package barman available**.  
> item: barman  
> msg: Failed to install some of the specified packages  
> rc: 1  
> results:

I adapted it from [https://www.postgresql.org/download/linux/redhat/](https://www.postgresql.org/download/linux/redhat/)

can anybody advise where I am falling short in this?

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [March 20, 2022, 11:23am UTC](https://forum.ansible.com/t/dnf-install-postgresql-fom-postgresql-org-yum-repos/36463/2 "2022-03-20T11:23:29Z")

</div>

Hi,

You are specifying RPM url location in `enablerepo`, whereas `enablerepo` expects the name of the repoids. You may need to install the Postgresql rpm first and then use the repo in a subsequent task.

_- name: Install Postgresql official repo_  
_dnf:_  
_name: [https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86\_64/pgdg-redhat-repo-latest.noarch.rpm](https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm)_  
_state: latest_  
_disable\_gpg\_check: yes_

_- name: Install packages_  
_dnf:_  
_name: “{{ item }}”_  
_state: “present”_  
_with\_items:_  
_- postgresql_  
_- postgresql-server_
