misc: simply fastpackages logic and reduce play time
parent
d5bf0a195a
commit
bf26c727a8
|
@ -1,14 +0,0 @@
|
||||||
---
|
|
||||||
- block:
|
|
||||||
- name: "Check if package {{ package_name }} is already installed"
|
|
||||||
ansible.builtin.command: rpm -q {{ package_name }}
|
|
||||||
args:
|
|
||||||
warn: no
|
|
||||||
register: rpm_info
|
|
||||||
changed_when: rpm_info.failed
|
|
||||||
|
|
||||||
rescue:
|
|
||||||
- name: "Add {{ package_name }} to the yum install list if missing"
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
packages_to_install: "{{ packages_to_install + [ package_name ] }}"
|
|
||||||
when: rpm_info.failed
|
|
|
@ -1,18 +1,21 @@
|
||||||
---
|
---
|
||||||
- name: Set facts
|
- block:
|
||||||
ansible.builtin.set_fact:
|
- name: "Check if packages are already installed"
|
||||||
update_cache: true
|
ansible.builtin.command: "rpm -q {{ packages_list | join(' ') }}"
|
||||||
packages_to_install: []
|
args:
|
||||||
|
warn: no
|
||||||
|
register: rpm_info
|
||||||
|
changed_when: rpm_info.failed
|
||||||
|
|
||||||
- name: "Check packages to be installed"
|
rescue:
|
||||||
ansible.builtin.include_tasks: check.yml
|
- name: "Add missing packages to the yum install list"
|
||||||
loop: "{{ packages_list | flatten }}"
|
ansible.builtin.set_fact:
|
||||||
loop_control:
|
packages_to_install: "{{ packages_to_install | default([]) + rpm_info.stdout_lines | map('regex_findall', 'package (.+) is not installed$') | flatten }}"
|
||||||
loop_var: package_name
|
when: rpm_info.failed
|
||||||
|
|
||||||
- name: "Install packages: {{ packages_to_install }}"
|
- name: "Install packages: {{ packages_to_install }}"
|
||||||
become: yes
|
become: yes
|
||||||
ansible.builtin.yum:
|
ansible.builtin.yum:
|
||||||
name: "{{ packages_to_install }}"
|
name: "{{ packages_to_install }}"
|
||||||
state: present
|
state: present
|
||||||
when: packages_to_install | length > 0
|
when: packages_to_install | default([]) | length > 0
|
|
@ -30,12 +30,12 @@
|
||||||
state: absent
|
state: absent
|
||||||
when: existing_deploy.stat.exists and keycloak_force_install|bool
|
when: existing_deploy.stat.exists and keycloak_force_install|bool
|
||||||
|
|
||||||
- name: check for an existing deployment after possible forced removal
|
- name: Check for an existing deployment after possible forced removal
|
||||||
become: yes
|
become: yes
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ keycloak_jboss_home }}"
|
path: "{{ keycloak_jboss_home }}"
|
||||||
|
|
||||||
- name: create Keycloak service user/group
|
- name: Create Keycloak service user/group
|
||||||
become: yes
|
become: yes
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: "{{ keycloak_service_user }}"
|
name: "{{ keycloak_service_user }}"
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
system: yes
|
system: yes
|
||||||
create_home: no
|
create_home: no
|
||||||
|
|
||||||
- name: create Keycloak install location
|
- name: Create Keycloak install location
|
||||||
become: yes
|
become: yes
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
dest: "{{ keycloak_dest }}"
|
dest: "{{ keycloak_dest }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- name: start keycloak
|
- name: Start keycloak
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: keycloak
|
name: keycloak
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
Loading…
Reference in New Issue