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

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.