--- - name: check if yum is working and register the microsoft repositories hosts: all become: yes become_user: root tasks: - name: Install packages ansible.builtin.yum: name: - unzip - yum-utils state: present - name: reread all repostioris ansible.builtin.command: argv: - /usr/sbin/subscription-manager - list - --available - name: Check if the 7 repo still exits ansible.builtin.shell: /usr/sbin/subscription-manager repos | grep "Microsoft Repo 7" register: repo7exists ignore_errors: true - name: Result of repo 7 Test debug: msg="Microsoft Repo 7 still registered" when: repo7exists.rc == 0 - name: Add Microsoft Repository for Redhat 7 ansible.builtin.command: argv: - /usr/sbin/subscription-manager - attach - --pool=2c9fa5b47569b04401812974ef080567 when: ( ansible_os_family == "RedHat" and ansible_distribution_major_version == "7") and repo7exists.rc == 1 - name: Check if the 8 repo still exits ansible.builtin.shell: /usr/sbin/subscription-manager repos | grep "Microsoft Repo 8" register: repo8exists ignore_errors: true - name: Result of repo 8 test debug: msg="Microsoft Repo 8 still registered" when: repo8exists.rc == 0 - name: Add Microsoft Repository for Redhat 8 ansible.builtin.command: argv: - /usr/sbin/subscription-manager - attach - --pool=2c9fa5b47569b04401866662810e88059 when: ( ansible_os_family == "RedHat" and ansible_distribution_major_version == "8") and repo8exists.rc == 1 - name: copy the Microsoft Key ansible.builtin.template: src: templates/microsoft.asc dest: /root/microsoft.asc owner: root group: root mode: '0644' - name : Install the key ansible.builtin.command: argv: - /usr/bin/rpm - -import - /root/microsoft.asc - name : refesch yum cache ansible.builtin.command: argv: - /usr/bin/yum - makecache