Last active
April 5, 2019 13:36
-
-
Save nirebu/3a0574645277fb2003e8e55eb2e9ed4e to your computer and use it in GitHub Desktop.
Ensure open-vm-tools is excluded from /etc/yum.conf after installing the latest version from source #ansible #open-vm-tools #yum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: OPEN VM TOOLS | Checking how many matches are there for the lines exclude and open-vm-tools | |
shell: (grep -oP "(^exclude=|open-vm-tools)" /etc/yum.conf | wc -l) || true | |
register: test_grep | |
# 0 matches: will add the exclude line with open-vm-tools | |
# 1 match: only exclude present, unless it's a badly formatted /etc/yum.conf or the second pattern is in some comment | |
# 2 matches: both patterns present, will do nothing | |
- debug: | |
msg: "Matches: {{ test_grep.stdout }}" | |
- name: OPEN VM TOOLS | Appending to exclude only the string 'open-vm-tools*' since it's already present | |
lineinfile: | |
dest: /etc/yum.conf | |
regexp: '(^exclude.*)' | |
backrefs: yes | |
line: '\1 open-vm-tools*' | |
state: present | |
when: test_grep.stdout == "1" | |
- name: OPEN VM TOOLS | Adding the exclude line | |
lineinfile: | |
dest: /etc/yum.conf | |
line: 'exclude=open-vm-tools*' | |
state: present | |
when: test_grep.stdout == "0" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment