Restarting Httpd services

Task 11.3 Description :-                                                                                ðŸ”° 11.3 Restarting HTTPD Service is not idempotence in nature and also consume more resources suggest a way to rectify this challenge in Ansible playbook.


Using Handlers:


- hosts: web3

  vars_files: httpd_var.yml

  tasks:

- file:

      path: "/dvd"

      state: directory

    ignore_errors: yes


- mount:

      src: "/dev/cdrom"

      path: "/dvd"

      fstype: iso9660

      state: mounted

    ignore_errors: yes


- yum_repository:

      baseurl: file:///dvd/BaseOS

      name: "dvd1"

      description: "BaseOS"

      gpgcheck: no


- yum_repository:

      baseurl: file:///dvd/AppStream

      name: "dvd2"

      description: "AppStream"

      gpgcheck: no


- package:

      name: "httpd"

      state: present


- template:

      dest: "/etc/httpd/conf.d/l.conf"

      src: "l.conf"

    register: temp


  - debug:

          var: temp


handlers:

  - service:

      name: "httpd"

      state: restarted

      enabled: yes


  - firewalld:

      port: "{{ port }}/tcp"

      state: enabled

      permanent: yes

      immediate: yes


Comments

Popular posts from this blog

Docker with Ansible

Summer Task 7 - (07.2 )

HAPORXY