From 4b4d17aee321992cb20123d1304ee9aa2ed624a4 Mon Sep 17 00:00:00 2001 From: Giovanni Toraldo Date: Tue, 19 Sep 2023 11:17:37 +0200 Subject: [PATCH] wip identity role --- .github/workflows/community.yml | 1 + requirements.yml | 7 +++- roles/identity/.gitignore | 1 + roles/identity/README.md | 38 +++++++++++++++++++ roles/identity/defaults/main.yml | 2 + roles/identity/handlers/main.yml | 2 + roles/identity/meta/main.yml | 24 ++++++++++++ roles/identity/molecule/default/converge.yml | 7 ++++ .../default/host_vars/identity-instance.yml | 1 + roles/identity/molecule/default/molecule.yml | 29 ++++++++++++++ roles/identity/molecule/default/verify.yml | 34 +++++++++++++++++ roles/identity/tasks/main.yml | 8 ++++ roles/identity/tests/inventory | 1 + roles/identity/tests/test.yml | 5 +++ roles/identity/vars/main.yml | 2 + 15 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 roles/identity/.gitignore create mode 100644 roles/identity/README.md create mode 100644 roles/identity/defaults/main.yml create mode 100644 roles/identity/handlers/main.yml create mode 100644 roles/identity/meta/main.yml create mode 100644 roles/identity/molecule/default/converge.yml create mode 100644 roles/identity/molecule/default/host_vars/identity-instance.yml create mode 100644 roles/identity/molecule/default/molecule.yml create mode 100644 roles/identity/molecule/default/verify.yml create mode 100644 roles/identity/tasks/main.yml create mode 100644 roles/identity/tests/inventory create mode 100644 roles/identity/tests/test.yml create mode 100644 roles/identity/vars/main.yml diff --git a/.github/workflows/community.yml b/.github/workflows/community.yml index 6c95b7c33..6d949f793 100644 --- a/.github/workflows/community.yml +++ b/.github/workflows/community.yml @@ -25,6 +25,7 @@ jobs: - name: activemq - name: common - name: elasticsearch + - name: identity - name: java - name: nginx - name: postgres diff --git a/requirements.yml b/requirements.yml index 2e19f375a..7a9f9867d 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,15 +1,18 @@ --- +# Install with ansible-galaxy coillection install -vr requirements.yml collections: - name: community.general version: 4.4.0 - name: community.postgresql version: 2.1.0 - name: ansible.posix - version: 1.3.0 + version: 1.5.4 - name: ansible.utils version: 2.6.0 - name: community.crypto version: 2.10.0 + - name: middleware_automation.keycloak + version: 1.2.8 # molecule ec2 tests - name: amazon.aws version: 6.3.0 @@ -18,6 +21,8 @@ collections: # molecule roles tests - name: community.docker version: 2.1.1 + +# Install with ansible-galaxy role install -vr requirements.yml roles: - name: buluma.elastic_repo version: v0.1.2 diff --git a/roles/identity/.gitignore b/roles/identity/.gitignore new file mode 100644 index 000000000..a1346bb49 --- /dev/null +++ b/roles/identity/.gitignore @@ -0,0 +1 @@ +keycloak-*.zip diff --git a/roles/identity/README.md b/roles/identity/README.md new file mode 100644 index 000000000..225dd44b9 --- /dev/null +++ b/roles/identity/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/identity/defaults/main.yml b/roles/identity/defaults/main.yml new file mode 100644 index 000000000..afbf2a452 --- /dev/null +++ b/roles/identity/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for identity diff --git a/roles/identity/handlers/main.yml b/roles/identity/handlers/main.yml new file mode 100644 index 000000000..2eda5522f --- /dev/null +++ b/roles/identity/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for identity diff --git a/roles/identity/meta/main.yml b/roles/identity/meta/main.yml new file mode 100644 index 000000000..1a2f43588 --- /dev/null +++ b/roles/identity/meta/main.yml @@ -0,0 +1,24 @@ +galaxy_info: + author: Alfresco + namespace: alfresco + description: Install Keycloak to enable SSO in Alfresco + company: Hyland Software + + license: Apache-2.0 + + min_ansible_version: "2.12" + + platforms: + - name: Ubuntu + versions: + - focal + - bionic + - name: EL + versions: + - "7" + - "8" + + galaxy_tags: [] + +dependencies: + - role: common diff --git a/roles/identity/molecule/default/converge.yml b/roles/identity/molecule/default/converge.yml new file mode 100644 index 000000000..6ea4ae866 --- /dev/null +++ b/roles/identity/molecule/default/converge.yml @@ -0,0 +1,7 @@ +--- +- name: Converge + hosts: all + tasks: + - name: "Include identity" + ansible.builtin.include_role: + name: "identity" diff --git a/roles/identity/molecule/default/host_vars/identity-instance.yml b/roles/identity/molecule/default/host_vars/identity-instance.yml new file mode 100644 index 000000000..146ddd8e0 --- /dev/null +++ b/roles/identity/molecule/default/host_vars/identity-instance.yml @@ -0,0 +1 @@ +ansible_user: ansible diff --git a/roles/identity/molecule/default/molecule.yml b/roles/identity/molecule/default/molecule.yml new file mode 100644 index 000000000..32855b48d --- /dev/null +++ b/roles/identity/molecule/default/molecule.yml @@ -0,0 +1,29 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: identity-instance + image: $MOLECULE_ROLE_IMAGE + dockerfile: ../../../../tests/molecule/Dockerfile-noprivs.j2 + command: "/lib/systemd/systemd" + privileged: true + tmpfs: + - /run + - /run/lock + - /tmp + volume_mounts: + - "/sys/fs/cgroup:/sys/fs/cgroup:ro" + groups: + - identity + published_ports: + - 0.0.0.0:8080:8080/tcp +provisioner: + name: ansible + inventory: + links: + host_vars: host_vars + group_vars: ../../../../group_vars +verifier: + name: ansible diff --git a/roles/identity/molecule/default/verify.yml b/roles/identity/molecule/default/verify.yml new file mode 100644 index 000000000..7201fc912 --- /dev/null +++ b/roles/identity/molecule/default/verify.yml @@ -0,0 +1,34 @@ +- name: Verify + hosts: all + gather_facts: false + tasks: + + - name: Stat the tmp folder for identity + ansible.builtin.stat: + path: "/usr/share/identity/tmp" + register: tmp_path_stat + + - name: Assert that tmp folder is setup correctly + ansible.builtin.assert: + that: + - tmp_path_stat.stat.exists + - tmp_path_stat.stat.isdir + - tmp_path_stat.stat.mode == '0777' + - tmp_path_stat.stat.uid == 0 + - tmp_path_stat.stat.gid == 0 + + - name: Check if port 9200/tcp is listening + ansible.builtin.wait_for: + port: 9200 + timeout: 30 + connect_timeout: 1 + msg: "Timeout waiting for 9200/tcp to respond" + + - name: Populate service facts + ansible.builtin.service_facts: + + - name: Identity service is up and running + ansible.builtin.assert: + that: + - ansible_facts.services['identity.service'] is defined + - ansible_facts.services['identity.service'].state == 'running' diff --git a/roles/identity/tasks/main.yml b/roles/identity/tasks/main.yml new file mode 100644 index 000000000..b6c48d869 --- /dev/null +++ b/roles/identity/tasks/main.yml @@ -0,0 +1,8 @@ +--- +# tasks file for identity +- name: Install Keycloak + vars: + keycloak_quarkus_admin_pass: "alfrescoalfrescoadmin" + keycloak_quarkus_version: 21.1.2 + ansible.builtin.include_role: + name: middleware_automation.keycloak.keycloak_quarkus diff --git a/roles/identity/tests/inventory b/roles/identity/tests/inventory new file mode 100644 index 000000000..2fbb50c4a --- /dev/null +++ b/roles/identity/tests/inventory @@ -0,0 +1 @@ +localhost diff --git a/roles/identity/tests/test.yml b/roles/identity/tests/test.yml new file mode 100644 index 000000000..61fb0ce17 --- /dev/null +++ b/roles/identity/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - identity diff --git a/roles/identity/vars/main.yml b/roles/identity/vars/main.yml new file mode 100644 index 000000000..b61a2d178 --- /dev/null +++ b/roles/identity/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for identity