---
- hosts: all
  tasks:
    - name: Allow pam_pkc11 module to be removed. (RHEL7=>8)
      copy:
        dest: /var/log/leapp/answerfile
        content: |
          [remove_pam_pkcs11_module_check]
          confirm = True
        mode: "0644"
      when:
        - ansible_distribution_major_version == "7"

    - name: Set beaker-harness repo to use RHEL8 (RHEL7=>8)
      command:
        argv:
          - sed
          - -i
          - s/RedHatEnterpriseLinux7/RedHatEnterpriseLinux8/
          - /etc/yum.repos.d/beaker-harness.repo
      when:
        - ansible_distribution_major_version == "7"

    - name: Set beaker-harness repo to use RHEL9 (RHEL8=>9)
      command:
        argv:
          - sed
          - -i
          - s/RedHatEnterpriseLinux8/RedHatEnterpriseLinux9/
          - /etc/yum.repos.d/beaker-harness.repo
      when:
        - ansible_distribution_major_version == "8"

    - name: Run LEAPP upgrade
      command:
        argv:
          - leapp
          - upgrade
          - --enablerepo
          - beaker-harness
      environment:
        LEAPP_DEVEL_DATABASE_SYNC_OFF: 1
        LEAPP_DEVEL_RPMS_ALL_SIGNED: 1
        LEAPP_UNSUPPORTED: 1

    - name: Reboot (using rhts-reboot)
      command:
        argv:
          - rhts-reboot
