# Update the IPs for new Aspace instances 
# call by --limit=<current version> --extra-vars="previous_version=<previous version>"
---
-   hosts: aspace_instances
    vars:
    pre_tasks:
      - fail: msg='Need to set previous version by adding --extra-vars "previous_version=<previous-version i.e. v2.0.1>" to ansible-playbook call'
        when: previous_version == None
      - debug: var=previous_version
    tasks:
      - debug: var=client_name
      - debug: 
          var: hostvars['{{ client_name }}-{{ previous_version}}']['ansible_ssh_host']
      - set_fact:
          old_host: "{{ client_name }}-{{ previous_version}}"
      - set_fact:
          old_host_ip: "{{ hostvars[old_host]['ansible_ssh_host'] }}"
      - name: change the IP from previous to current in nginx.conf
        replace:
          dest: /etc/nginx/nginx.conf
          regexp: "{{ old_host_ip }}"
          replace: "{{ ansible_ssh_host }}"
        become: yes
        delegate_to: 127.0.0.1


Automate update of IPs in nginx.conf!!!!
Automate update of IPs in nginx.conf!!!!
