cancel
Showing results for 
Search instead for 
Did you mean: 
Trevor
Commander Commander
Commander
  • 151 Views

Install Packages via Ansible Playbook

I want to install the following packages on Red Hat managed nodes:
httpd
httpd-devel
httpd-tools


What would my playbook entry look like to achieve this?

 

 

Trevor "Red Hat Evangelist" Chandler
Labels (3)
2 Replies
Akyuz_Remzi
Flight Engineer
Flight Engineer
  • 125 Views

only_install_packages.jpg

This playbook install the required packages only.
If you want to use the http service, you should not forget to enable the httpd service and allow http traffic in the firewall.

enable http service:
- name: Enable and start httpd service
 service:
  name: httpd
  state: started
  enabled: yes
- name: allow http service in firewalld
 firewalld:
  service: http
 permanent: yes
  state: enabled
  immediate: yes
when: ansible_facts.service["firewalld.service"] is defined

There may be a typo. I recommended checking the help documentation against possible syntax error.
example: $ ansible-navigator doc ansible.builtin.yum

Chetan_Tiwary_
Community Manager
Community Manager
  • 68 Views

@Trevor your friend here is dnf / yum module. You can apply a list of packages to the module for the job :

tasks:
    - name: Install httpd and other packages
      dnf:
        name:
          - httpd
          - httpd-devel
          - httpd-tools
        state: present

https://www.redhat.com/en/blog/software-packages-ansible 

Join the discussion
You must log in to join this conversation.