---
- name: RollBack Rpm versions for {{ service_name }}
hosts: local
connection: local
gather_facts: false
tasks:
- name: Getting host list from ipa
shell: /etc/ansible/playbooks/hostfind.sh
- name: Creating in memory inventory group for {{ nodetype }} in ansible playbook itself
shell: cat /etc/ansible/hosts | grep {{ nodetype }} | grep {{ env }}
register: host_list
- add_host:
name: "{{ item }}"
group: "{{ nodetype }}"
with_items: "{{ host_list.stdout_lines }}"
- name: Rollback Execution start on {{ nodetype }}
hosts: "{{ nodetype }}"
connection: ssh
gather_facts: false
any_errors_fatal: false
user: test
become: yes
serial: 1
tasks:
- name: Rolling back service on {{ inventory_hostname }}
block:
- name: Downgrading Rpm {{ service_name }}
shell: yum downgrade "{{ service_name }}" -y
- name: Getting Version of {{ service_name }} in {{ inventory_hostname }}
shell: rpm --queryformat "%{VERSION}-%{RELEASE}" -q "{{ service_name }}"
register: downgraderpmversion
- name: Restarting {{ service_name }} service on {{ inventory_hostname }}
include_tasks: /etc/ansible/inventories/playbooks/common/service_restart.yaml
with_items:
- { servicename: '{{ service_name }}' }
- name: wait for 60 second to come up the service {{ service_name }} on {{ inventory_hostname }}
wait_for:
port: "{{ port_num }}"
host: '{{ inventory_hostname }}'
- name: Updating Rpm versions for {{ service_name }}
hosts: local
connection: local
gather_facts: false
tasks:
- debug:
var: hostvars[groups['{{ nodetype }}'][0]]['downgraderpmversion']['stdout']
- shell: echo hostvars[groups['{{ nodetype }}'][0]]['downgraderpmversion']['stdout']