Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPSEXP-2880 Add audit-storage role #996

Merged
merged 15 commits into from
Dec 3, 2024
Merged
1 change: 1 addition & 0 deletions .github/workflows/enteprise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
- name: sfs
- name: sync
- name: trouter
- name: audit_storage
steps:
- name: Share var with further reusable workflows
id: jobvars
Expand Down
8 changes: 8 additions & 0 deletions group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ api_explorer:
artifact_name: api-explorer
repository: "{{ nexus_repository.releases }}"
version: 23.4.0
audit_storage:
artifact_name: alfresco-audit-storage-distribution
repository: "{{ nexus_repository.enterprise_releases }}"
version: 1.0.0
search_enterprise:
artifact_name: alfresco-elasticsearch-connector-distribution
repository: "{{ nexus_repository.enterprise_releases }}"
Expand Down Expand Up @@ -122,6 +126,10 @@ downloads:
{{ adw.repository }}/{{ adw.artifact_name }}/{{ adw.version }}/{{ adw.artifact_name }}-{{ adw.version }}.zip
adw_zip_sha1_checksum_url: >-
{{ adw.repository }}/{{ adw.artifact_name }}/{{ adw.version }}/{{ adw.artifact_name }}-{{ adw.version }}.zip.sha1
audit_storage_zip_url: >-
{{ audit_storage.repository }}/{{ audit_storage.artifact_name }}/{{ audit_storage.version }}/{{ audit_storage.artifact_name }}-{{ audit_storage.version }}.zip
audit_storage_zip_sha1_checksum_url: >-
{{ audit_storage.repository }}/{{ audit_storage.artifact_name }}/{{ audit_storage.version }}/{{ audit_storage.artifact_name }}-{{ audit_storage.version }}.zip.sha1
search_enterprise_zip_url: >-
{{ search_enterprise.repository }}/{{ search_enterprise.artifact_name }}/{{ search_enterprise.version }}/{{ search_enterprise.artifact_name }}-{{ search_enterprise.version }}.zip
search_enterprise_zip_sha1_url: >-
Expand Down
4 changes: 4 additions & 0 deletions inventory_ha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ all:
hosts:
sync.infra.local:

audit_storage:
hosts:
audit.infra.local:

other_repo_clients:
hosts:

Expand Down
4 changes: 4 additions & 0 deletions inventory_local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ all:
children:
repository:

audit_storage:
children:
repository:

other_repo_clients:
hosts:

Expand Down
5 changes: 5 additions & 0 deletions inventory_ssh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ all:
syncservice_1:
ansible_host: targetIP

audit_storage:
hosts:
audit_storage_1:
ansible_host: targetIP

other_repo_clients:
hosts:

Expand Down
1 change: 1 addition & 0 deletions molecule/docker_enterprise/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ platforms:
- acc
- adw
- nginx
- audit_storage
published_ports:
- 0.0.0.0:443:443/tcp

Expand Down
14 changes: 14 additions & 0 deletions molecule/docker_enterprise/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- name: Verify
hosts: all
gather_facts: true
tasks:
- name: Populate services facts
ansible.builtin.service_facts:

- name: Check services up
ansible.builtin.assert:
quiet: true
that:
- ansible_facts.services['nginx.service'].state == "running"
- ansible_facts.services['alfresco-audit-storage.service'].state == "running"
41 changes: 41 additions & 0 deletions playbooks/acs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,44 @@
mode: "0755"
tags:
- sync

- name: Audit Storage Role
hosts: audit_storage
gather_facts: false
vars:
acs_version_requirement: "{{ acs.version is version('23.4', 'ge') }}"
pre_tasks:
- name: Assert that the required version is met
ansible.builtin.fail:
msg: "Audit Storage requires ACS 23.4 or later"
when: not acs_version_requirement
roles:
- role: "../roles/audit_storage"
when: acs.edition == "Enterprise" and acs_version_requirement
audit_storage_version: "{{ audit_storage.version }}"
audit_storage_zip_url: "{{ downloads.audit_storage_zip_url }}"
audit_storage_zip_sha1_url: "{{ downloads.audit_storage_zip_sha1_checksum_url }}"
audit_storage_username: "{{ username }}"
audit_storage_group_name: "{{ group_name }}"
audit_storage_broker_url: "failover:({{ activemq_transport }}://{{ activemq_host }}:{{ ports_cfg.activemq[activemq_protocol] }})"
audit_storage_broker_username: "{{ activemq_username }}"
audit_storage_broker_password: "{{ activemq_password }}"
audit_storage_opensearch_url: "{{ elasticsearch_protocol }}://{{ elasticsearch_host }}:{{ ports_cfg.elasticsearch.http }}"
audit_storage_opensearch_username: "{{ elasticsearch_username }}"
audit_storage_opensearch_password: "{{ elasticsearch_password }}"
post_tasks:
- name: Update installation status file with Audit Storage
when: acs.edition == "Enterprise" and acs_version_requirement
become: true
vars:
audit_storage_components:
audit_storage: "{{ audit_storage }}"
ansible.builtin.blockinfile:
block: "{{ audit_storage_components | to_nice_yaml(indent=2) }}"
create: true
path: "{{ ansible_installation_status_file }}"
marker_begin: AUDIT_STORAGE_BEGIN
marker_end: AUDIT_STORAGE_END
mode: "0755"
tags:
- audit_storage
38 changes: 38 additions & 0 deletions roles/audit_storage/README.md
gionn marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -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).
45 changes: 45 additions & 0 deletions roles/audit_storage/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
# defaults file for audit_storage
audit_storage_version: "1.0.0"
audit_storage_zip_url: https://nexus.alfresco.com/nexus/repository/enterprise-releases/org/alfresco/alfresco-audit-storage-distribution/{{ audit_storage_version }}/alfresco-audit-storage-distribution-{{ audit_storage_version }}.zip
audit_storage_zip_sha1_url: https://nexus.alfresco.com/nexus/repository/enterprise-releases/org/alfresco/alfresco-audit-storage-distribution/{{ audit_storage_version }}/alfresco-audit-storage-distribution-{{ audit_storage_version }}.zip.sha1

audit_storage_artifact_name: alfresco-audit-storage-app

audit_storage_username: alfresco
audit_storage_group_name: alfresco

audit_storage_broker_url: failover:(nio://localhost:61616)?timeout=3000
audit_storage_broker_username: admin
audit_storage_broker_password: admin
gionn marked this conversation as resolved.
Show resolved Hide resolved
audit_storage_opensearch_url: http://localhost:9200
audit_storage_opensearch_username: ''
audit_storage_opensearch_password: ''

audit_storage_default_environment:
SPRING_ACTIVEMQ_BROKERURL: "{{ audit_storage_broker_url }}"
SPRING_ACTIVEMQ_USER: "{{ audit_storage_broker_username }}"
SPRING_ACTIVEMQ_PASSWORD: "{{ audit_storage_broker_password }}"
AUDIT_ENTRYSTORAGE_OPENSEARCH_CONNECTOR_URI: "{{ audit_storage_opensearch_url }}"
AUDIT_ENTRYSTORAGE_OPENSEARCH_CONNECTOR_USERNAME: "{{ audit_storage_opensearch_username }}"
AUDIT_ENTRYSTORAGE_OPENSEARCH_CONNECTOR_PASSWORD: "{{ audit_storage_opensearch_password }}"
AUDIT_EVENTINGESTION_URI: activemq:topic:alfresco.repo.event2
audit_storage_environment: {}

audit_storage_java_bin_path: /opt/openjdk-17.0.11/bin/java

audit_storage_binaries_dir: "/opt/alfresco/audit-storage-{{ audit_storage_version }}"
audit_storage_config_dir: "/etc/alfresco/audit-storage"

audit_storage_systemd_service_unit_name: "alfresco-audit-storage"
audit_storage_systemd_service_unit_description: "Alfresco Audit Storage"
audit_storage_systemd_service_exec_start: "{{ audit_storage_java_bin_path }} -jar {{ audit_storage_artifact_path }}"
audit_storage_systemd_service_user: "{{ audit_storage_username }}"

audit_storage_systemd_service_unit_after: syslog.target network.target local-fs.target remote-fs.target nss-lookup.target
audit_storage_systemd_service_type: simple
audit_storage_systemd_service_exec_stop: kill -15 $MAINPID
audit_storage_systemd_service_working_directory: /tmp
audit_storage_systemd_service_additional_options: {}
audit_storage_systemd_service_state: started
audit_storage_systemd_service_enabled: true
13 changes: 13 additions & 0 deletions roles/audit_storage/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
# handlers file for audit_storage
- name: Reload systemd
become: true
ansible.builtin.systemd:
daemon_reload: true

- name: Restart {{ audit_storage_systemd_service_unit_name }}
become: true
ansible.builtin.systemd:
name: "{{ audit_storage_systemd_service_unit_name }}"
state: restarted
when: audit_storage_systemd_service_state == 'started'
33 changes: 33 additions & 0 deletions roles/audit_storage/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
galaxy_info:
author: Alfresco Ops Readiness
description: This role installs and configures the audit storage for Alfresco
company: Hyland Software

# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker

license: Apache-2.0

min_ansible_version: "2.12"

platforms:
- name: Ubuntu
versions:
- bionic
- focal
- name: EL
versions:
- "8"
- "9"

galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.

dependencies:
- role: java
7 changes: 7 additions & 0 deletions roles/audit_storage/molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Converge
hosts: all
roles:
- role: activemq
- role: elasticsearch
- role: audit_storage
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ansible_user: ansible
32 changes: 32 additions & 0 deletions roles/audit_storage/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: 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:
- audit_storage
- activemq
- elasticsearch
provisioner:
name: ansible
ansible_args:
- -e
- "@../../../../tests/molecule/secrets.yml"
inventory:
links:
group_vars: ../../../../group_vars
host_vars: host_vars
verifier:
name: ansible
14 changes: 14 additions & 0 deletions roles/audit_storage/molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- name: Verify
hosts: instance
gather_facts: false
tasks:
- name: Populate service facts
ansible.builtin.service_facts:

- name: Check that service is up and running
ansible.builtin.assert:
that:
- ansible_facts.services['alfresco-audit-storage.service'] is defined
- ansible_facts.services['alfresco-audit-storage.service'].state == 'running'
quiet: true
48 changes: 48 additions & 0 deletions roles/audit_storage/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
# tasks file for audit_storage
- name: Download audit storage distribution {{ audit_storage_version }}
ansible.builtin.get_url:
url: "{{ audit_storage_zip_url }}"
dest: "{{ download_location }}/{{ audit_storage_artifact_name }}-{{ audit_storage_version }}.zip"
checksum: sha1:{{ lookup('url', audit_storage_zip_sha1_url, username=nexus_user, password=nexus_password) }} # pragma: allowlist secret
mode: "0644"
url_username: "{{ nexus_user }}"
url_password: "{{ nexus_password }}"

- name: Install Audit Storage
become: true
block:
- name: Create directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ audit_storage_username }}"
group: "{{ audit_storage_group_name }}"
mode: "0755"
loop:
- "{{ audit_storage_binaries_dir }}"
- "{{ audit_storage_config_dir }}"

- name: Extract distribution zip in binaries
ansible.builtin.unarchive:
src: "{{ download_location }}/{{ audit_storage_artifact_name }}-{{ audit_storage_version }}.zip"
dest: "{{ audit_storage_binaries_dir }}"
remote_src: true
creates: "{{ audit_storage_binaries_dir }}/README.md"
owner: "{{ audit_storage_username }}"
group: "{{ audit_storage_group_name }}"

- name: Create systemd service
ansible.builtin.template:
src: systemd-service.j2
dest: /etc/systemd/system/{{ audit_storage_systemd_service_unit_name }}.service
mode: "0644"
notify:
- Reload systemd
- Restart {{ audit_storage_systemd_service_unit_name }}

- name: Start service
ansible.builtin.systemd:
name: "{{ audit_storage_systemd_service_unit_name }}"
state: "{{ audit_storage_systemd_service_state }}"
enabled: "{{ audit_storage_systemd_service_enabled }}"
Loading
Loading