playbook.yml
[student@workstation dev-failures]$ cat playbook.yml 
---
- hosts: databases
  vars:
    web_package: httpd
    db_package: mariadb-server
    db_service: mariadb

  tasks:
    - name: Check local time
      command: date
      register: command_result
      changed_when: false

    - name: Print local time
      debug:
        var : command_result["stdout"]

    - block:
      - name: Install {{ web_package }} package
        yum:
          name: "{{ web_package }}"
          state: latest
      rescue:
      - name: Install {{ db_package }} package
        yum:
          name: "{{ db_package }}"
          state: latest
      always:
      - name: Start {{ db_service }} service
        service:
          name: "{{ db_service }}"
          state: started
  • No labels
Write a comment…