mirror of
https://github.com/ansible-middleware/keycloak.git
synced 2025-04-05 10:20:27 -07:00
Merge pull request #169 from ansible-middleware/mol_sudo
Adapt molecule tests to work with none root user on target (sudo)
This commit is contained in:
commit
beee25dec2
4 changed files with 80 additions and 55 deletions
|
@ -1,16 +1,9 @@
|
|||
---
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: Install sudo
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- sudo
|
||||
- java-1.8.0-openjdk
|
||||
state: present
|
||||
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
gather_facts: yes
|
||||
vars:
|
||||
sudo_pkg_name: sudo
|
||||
tasks:
|
||||
- name: "Run preparation common to all scenario"
|
||||
ansible.builtin.include_tasks: ../prepare.yml
|
||||
|
@ -18,3 +11,12 @@
|
|||
assets:
|
||||
- "{{ assets_server }}/sso/7.6.0/rh-sso-7.6.0-server-dist.zip"
|
||||
- "{{ assets_server }}/sso/7.6.1/rh-sso-7.6.1-patch.zip"
|
||||
|
||||
- name: Install JDK8
|
||||
become: yes
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- java-1.8.0-openjdk
|
||||
state: present
|
||||
|
||||
|
||||
|
|
|
@ -56,31 +56,34 @@
|
|||
ansible.builtin.assert:
|
||||
that:
|
||||
- (keycloak_query_clients.json | selectattr('clientId','equalto','TestClient') | first)["attributes"]["post.logout.redirect.uris"] == '/public/logout'
|
||||
- name: Check log folder
|
||||
ansible.builtin.stat:
|
||||
path: "/tmp/keycloak"
|
||||
register: keycloak_log_folder
|
||||
- name: Check that keycloak log folder exists and is a link
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- keycloak_log_folder.stat.exists
|
||||
- not keycloak_log_folder.stat.isdir
|
||||
- keycloak_log_folder.stat.islnk
|
||||
- name: Check log file
|
||||
ansible.builtin.stat:
|
||||
path: "/tmp/keycloak/server.log"
|
||||
register: keycloak_log_file
|
||||
- name: Check if keycloak file exists
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- keycloak_log_file.stat.exists
|
||||
- not keycloak_log_file.stat.isdir
|
||||
- name: Check default log folder
|
||||
ansible.builtin.stat:
|
||||
path: "/var/log/keycloak"
|
||||
register: keycloak_default_log_folder
|
||||
failed_when: false
|
||||
- name: Check that default keycloak log folder doesn't exist
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- not keycloak_default_log_folder.stat.exists
|
||||
- name: "Privilege escalation as some files/folders may requires it"
|
||||
become: yes
|
||||
block:
|
||||
- name: Check log folder
|
||||
ansible.builtin.stat:
|
||||
path: "/tmp/keycloak"
|
||||
register: keycloak_log_folder
|
||||
- name: Check that keycloak log folder exists and is a link
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- keycloak_log_folder.stat.exists
|
||||
- not keycloak_log_folder.stat.isdir
|
||||
- keycloak_log_folder.stat.islnk
|
||||
- name: Check log file
|
||||
ansible.builtin.stat:
|
||||
path: "/tmp/keycloak/server.log"
|
||||
register: keycloak_log_file
|
||||
- name: Check if keycloak file exists
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- keycloak_log_file.stat.exists
|
||||
- not keycloak_log_file.stat.isdir
|
||||
- name: Check default log folder
|
||||
ansible.builtin.stat:
|
||||
path: "/var/log/keycloak"
|
||||
register: keycloak_default_log_folder
|
||||
failed_when: false
|
||||
- name: Check that default keycloak log folder doesn't exist
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- not keycloak_default_log_folder.stat.exists
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
---
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
gather_facts: yes
|
||||
vars:
|
||||
sudo_pkg_name: sudo
|
||||
tasks:
|
||||
- name: "Run preparation common to all scenario"
|
||||
ansible.builtin.include_tasks: ../prepare.yml
|
||||
|
|
|
@ -3,9 +3,27 @@
|
|||
ansible.builtin.debug:
|
||||
msg: "Ansible version is {{ ansible_version.full }}"
|
||||
|
||||
- name: Install sudo
|
||||
|
||||
- name: "Ensure {{ sudo_pkg_name }} is installed (if user is root)."
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
name: "{{ sudo_pkg_name }}"
|
||||
when:
|
||||
- ansible_user_id == 'root'
|
||||
|
||||
|
||||
- name: Gather the package facts
|
||||
ansible.builtin.package_facts:
|
||||
manager: auto
|
||||
|
||||
- name: "Check if {{ sudo_pkg_name }} is installed."
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- sudo_pkg_name in ansible_facts.packages
|
||||
|
||||
- name: Install sudo
|
||||
become: yes
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- sudo
|
||||
- iproute
|
||||
state: present
|
||||
|
@ -14,22 +32,21 @@
|
|||
ansible.builtin.set_fact:
|
||||
assets_server: "{{ lookup('env','MIDDLEWARE_DOWNLOAD_RELEASE_SERVER_URL') }}"
|
||||
|
||||
- name: "Set offline when assets server from env is defined"
|
||||
ansible.builtin.set_fact:
|
||||
sso_offline_install: True
|
||||
- name: "Download artefacts only if assets_server is set"
|
||||
when:
|
||||
- assets_server is defined
|
||||
- assets_server | length > 0
|
||||
block:
|
||||
- name: "Set offline when assets server from env is defined"
|
||||
ansible.builtin.set_fact:
|
||||
sso_offline_install: True
|
||||
|
||||
- name: "Download and deploy zips from {{ assets_server }}"
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ asset }}"
|
||||
dest: "{{ lookup('env', 'PWD') }}"
|
||||
validate_certs: no
|
||||
delegate_to: localhost
|
||||
loop: "{{ assets }}"
|
||||
loop_control:
|
||||
loop_var: asset
|
||||
when:
|
||||
- assets_server is defined
|
||||
- assets_server | length > 0
|
||||
- name: "Download and deploy zips from {{ assets_server }}"
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ asset }}"
|
||||
dest: "{{ lookup('env', 'PWD') }}"
|
||||
validate_certs: no
|
||||
delegate_to: localhost
|
||||
loop: "{{ assets }}"
|
||||
loop_control:
|
||||
loop_var: asset
|
||||
|
|
Loading…
Add table
Reference in a new issue