From a998433a399247d2718e4f0c5accd3c36c8b4742 Mon Sep 17 00:00:00 2001 From: B Stack Date: Fri, 3 Aug 2018 09:49:48 -0400 Subject: add SPDR --- .../set_permanent_dns_resolvers.yml | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 set-permanent-dns-resolvers/set_permanent_dns_resolvers.yml (limited to 'set-permanent-dns-resolvers/set_permanent_dns_resolvers.yml') 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 -- cgit