--- - name: Add VMWare tools repository. ansible.builtin.template: src: vmware-tools.repo.j2 dest: /etc/yum.repos.d/vmware-tools.repo mode: '0644' - name: Import VMWare tools GPG keys. ansible.builtin.rpm_key: key: "https://packages.vmware.com/tools/keys/VMWARE-PACKAGING-GPG-RSA-KEY.pub" state: present - name: Install vmware tools block: - name: Create temporary directories for VMware tools. ansible.builtin.file: path: "/tmp/{{ item }}" state: directory mode: '0755' loop: - vmfusion - vmfusion-archive - name: Mount VMware tools. ansible.posix.mount: name: /tmp/vmfusion src: /home/{{ local_account_username }}/linux.iso fstype: iso9660 opts: loop state: mounted - name: Find any VMwareTools file. ansible.builtin.find: paths: /tmp/vmfusion patterns: "^VMwareTools-*.tar.gz" use_regex: true register: vmware_tools_files - name: run the installer block: - name: Decompress VMware Tools installer into archive folder. ansible.builtin.unarchive: src: "{{ vmware_tools_files.files[0] }}" dest: /tmp/vmfusion-archive remote_src: true - name: Run the VMware tools installer. ansible.builtin.shell: /tmp/vmfusion-archive/vmware-tools-distrib/vmware-install.pl --default changed_when: false when: vmware_tools_files.matched > 0 always: - name: Unmount VMware tools. ansible.posix.mount: name: /tmp/vmfusion src: /home/{{ local_account_username }}/linux.iso fstype: iso9660 state: absent - name: Remove temporary directories for VMware tools. ansible.builtin.file: path: "/tmp/{{ item }}" state: absent loop: - vmfusion - vmfusion-archive - name: Delete VMware Tools. ansible.builtin.file: path: /home/{{ local_account_username }}/linux.iso state: absent