diff options
author | B Stack <bgstack15@gmail.com> | 2018-08-03 09:49:48 -0400 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2018-08-03 09:49:48 -0400 |
commit | a998433a399247d2718e4f0c5accd3c36c8b4742 (patch) | |
tree | b57f9c49994b27566502b581ea81e836c226455b /set-permanent-dns-resolvers/set_permanent_dns_resolvers.yml | |
parent | fetch-all-album-images: handle when download is obstructed by a prompt (diff) | |
download | former-gists-a998433a399247d2718e4f0c5accd3c36c8b4742.tar.gz former-gists-a998433a399247d2718e4f0c5accd3c36c8b4742.tar.bz2 former-gists-a998433a399247d2718e4f0c5accd3c36c8b4742.zip |
add SPDR
Diffstat (limited to 'set-permanent-dns-resolvers/set_permanent_dns_resolvers.yml')
-rw-r--r-- | set-permanent-dns-resolvers/set_permanent_dns_resolvers.yml | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/set-permanent-dns-resolvers/set_permanent_dns_resolvers.yml b/set-permanent-dns-resolvers/set_permanent_dns_resolvers.yml new file mode 100644 index 0000000..efe7698 --- /dev/null +++ b/set-permanent-dns-resolvers/set_permanent_dns_resolvers.yml @@ -0,0 +1,83 @@ +--- +# set_permanent_dns_resolvers.yml +# usage: +# ansible-playbook -i /etc/ansible/inv/all /etc/ansible/books/stable/set_permanent_dns_resolvers.yml -v -l clonetest209 + +- name: book that sets permanent dns resolvers + hosts: all + become: yes + become_user: root + become_method: sudo + vars: + dns_by_ipv4_network: + # DC1 PROD + 10.1.16.0: + - 10.1.17.1 + - 10.1.17.2 + # DC1 PROD 2 + 10.1.80.0: + - 10.1.17.1 + - 10.1.17.2 + # DC1 DMZ + 10.1.32.0: + - 10.1.33.58 + - 10.1.33.60 + # DC2 PROD + 10.2.16.0: + - 10.2.17.7 + - 10.2.17.8 + - gone + # DC2 PROD 2 + 10.2.80.0: + - 10.2.17.7 + - 10.2.17.8 + - gone + # DC2 DMZ + 10.2.32.0: + - 10.2.33.1 + - 10.2.33.2 + script_dir: '/etc/ansible/files' + script_file: 'set-permanent-dns-resolvers.sh' + tasks: + + - name: copy in rpm + copy: + src: /etc/ansible/files/rpms/bgscripts-core-1.3-8.noarch.rpm + dest: /tmp/ + mode: 0644 + changed_when: false + + - shell: rpm -U --nodeps /tmp/bgscripts-core-1.3-8.noarch.rpm + args: + warn: no + register: this_rpm + failed_when: + - 'not ("is already installed" in this_rpm.stdout or "is already installed" in this_rpm.stderr or this_rpm.rc == 0)' + changed_when: + - 'not ("is already installed" in this_rpm.stdout or "is already installed" in this_rpm.stderr)' + + - copy: + src: "{{ script_dir }}/{{ script_file }}" + dest: "/tmp/{{ script_file }}" + changed_when: false + + - shell: /bin/sh /tmp/{{ script_file }} -d1 + args: + warn: no + environment: + SPDR_DNS1: "{{ dns_by_ipv4_network[ansible_default_ipv4.network][0] | default(skip) }}" + SPDR_DNS2: "{{ dns_by_ipv4_network[ansible_default_ipv4.network][1] | default(skip) }}" + SPDR_DNS3: "{{ dns_by_ipv4_network[ansible_default_ipv4.network][2] | default(skip) }}" + register: this_script + changed_when: + - '"changed" in this_script.stdout' + + # cleanup + - file: + path: "/tmp/{{ item }}" + state: absent + ignore_errors: yes + changed_when: false + with_items: + - "{{ script_file }}" + - bgscripts-core-1.3-8.noarch.rpm |