diff --git a/molecule/jenkins_casc_check/converge.yml b/molecule/jenkins_casc_check/converge.yml new file mode 100644 index 0000000..c32e4e7 --- /dev/null +++ b/molecule/jenkins_casc_check/converge.yml @@ -0,0 +1,10 @@ +--- +- name: Converge + hosts: all + vars_files: + - vars.yml + tasks: + - name: Generate casc.yaml from template + ansible.builtin.template: + src: "../../roles/jenkins/templates/casc.yaml.j2" + dest: "/tmp/casc_generated.yaml" diff --git a/molecule/jenkins_casc_check/molecule.yml b/molecule/jenkins_casc_check/molecule.yml new file mode 100644 index 0000000..044ecd1 --- /dev/null +++ b/molecule/jenkins_casc_check/molecule.yml @@ -0,0 +1,35 @@ +--- +driver: + name: podman +platforms: + - name: instance + image: registry.access.redhat.com/ubi9/ubi-init:latest + pre_build_image: true + privileged: true + command: "/usr/sbin/init" + packages: + - sudo +provisioner: + name: ansible + playbooks: + prepare: prepare.yml + converge: converge.yml + verify: verify.yml + env: + ANSIBLE_FORCE_COLOR: "true" + ANSIBLE_ROLES_PATH: "../../roles" +verifier: + name: ansible +scenario: + test_sequence: + - cleanup + - destroy + - syntax + - create + - prepare + - converge + - idempotence + - side_effect + - verify + - cleanup + - destroy diff --git a/molecule/jenkins_casc_check/prepare.yml b/molecule/jenkins_casc_check/prepare.yml new file mode 100644 index 0000000..24daf9a --- /dev/null +++ b/molecule/jenkins_casc_check/prepare.yml @@ -0,0 +1,18 @@ +--- +- name: Prepare + hosts: all + gather_facts: yes + tasks: + + - name: "Include common prepare tasks" + ansible.builtin.include_tasks: ../prepare.yml + + - name: Ensure pip3 is installed + ansible.builtin.yum: + name: python3-pip + state: present + + - name: Install PyYAML + ansible.builtin.pip: + name: pyyaml + state: present diff --git a/molecule/jenkins_casc_check/vars.yml b/molecule/jenkins_casc_check/vars.yml new file mode 100644 index 0000000..e932169 --- /dev/null +++ b/molecule/jenkins_casc_check/vars.yml @@ -0,0 +1,143 @@ +jenkins: + groupname: "jenkins" + bind_addr: "localhost" + port: "8080" + username: "jenkins" + uid: "1000" + gid: "1000" + home: "/home/jenkins/current" + home_next: "/home/jenkins/next" + tools: + home: "/opt/tools" + executors: + num: "12" + default_jdk_home: "/opt/oracle/java" + default_mvn_home: "/opt/apache/maven" + default_mvn_settings: "/opt/tools/settings.xml" + jdk_list: + jdk8: "/opt/oracle/jdk1.8.0_181" + jdk17: "/opt/oracle/jdk-17.0.1" + admin: + id: "admin" + password: "admin_password" + ldap: + search: + group: + base: "" + filter: "" + inhibit_root_dn: false + rootDn: "" + host: "" + port: "636" + url: "" + role: + admin: + name: "admin" + group: "admins" + desc: "Administrator role" + ansibleCI: + name: "ansibleCI" + group: "ansible-ci-group" + desc: "Ansible CI role" + user: + name: "user" + group: "users" + desc: "Regular user role" + view: + - name: "Ansible AMQ Broker" + includeRegex: ".*amq.*" + - name: "Ansible CI" + includeRegex: "ansible-ci-.*" + - name: "Ansible DOT" + includeRegex: "ansible-downstream-tests-.*" + - name: "Ansible Demos" + includeRegex: ".*-demo" + - name: "Ansible Downstream CI" + includeRegex: "ansible-downstream-ci-.*" + - name: "Ansible Downstream Runner" + includeRegex: "ansible-downstream-runner-.*" + - name: "Ansible EAP" + includeRegex: ".*(wildfly|eap).*" + excludeRegex: '.*eap-[0-9]+\\.[0-9]+.*|wildfly-.*' + - name: "Ansible JWS" + includeRegex: ".*jws.*" + - name: "Ansible Janus" + includeRegex: "ansible-janus-.*" + - name: "Ansible Quarkus" + includeRegex: ".*quarkus.*" + - name: "Ansible Release" + includeRegex: "ansible-release-.*" + - name: "Component Alignment" + includeRegex: "component-alignment-.*" + - name: "SET CI" + includeRegex: "ci-.*" + - name: "eap-6.4.x" + includeRegex: 'eap-6\\.4\\.x-.*' + - name: "eap-7.0.x" + includeRegex: 'eap-7\\.0\\.x-.*' + - name: "eap-7.1.x" + includeRegex: 'eap-7\\.1\\.x-.*' + - name: "eap-7.2.x" + includeRegex: 'eap-7\\.2\\.x-.*' + - name: "eap-7.3.x" + includeRegex: 'eap-7\\.3\\.x-.*' + - name: "eap-7.4.x" + includeRegex: 'eap-7\\.4\\.x-.*' + - name: "eap-8.0.x" + includeRegex: 'eap-8\\.0\\.x-.*' + - name: "vbe" + includeRegex: "vbe-eap-.*" + - name: "vbe-wildfly" + includeRegex: "vbe-wildfly-.*" + - name: "wildfly" + includeRegex: "wildfly-.*" + - name: "xp-2.0.x" + includeRegex: 'xp-2\\.0\\.x-.*' + - name: "xp-3.0.x" + includeRegex: 'xp-3\\.0\\.x-.*' + - name: "xp-4.0.x" + includeRegex: 'xp-4\\.0\\.x-.*' + - name: "cryo" + includeRegex: "cryo-.*" + service: + - name: "hephaestus" + ip: "10.88.0.3" + location: "/jenkins" + readwrite_volumes: + - { src: "/home/jenkins/current", dest: "/var/jenkins_home" } + readonly_volumes: + - { src: "/home/jenkins/.ssh", dest: "/var/jenkins_home/.ssh" } + - { src: "/home/jenkins/.netrc", dest: "/var/jenkins_home/.netrc" } + - { src: "/home/jenkins/.gitconfig", dest: "/var/jenkins_home/.gitconfig" } + add_hosts: + - { src: "podman", ip: "10.88.0.3" } + - { src: "server", ip: "10.88.0.2" } + ports_mapping: + - { src: "8080", dest: "8080" } + vars: + - { name: "JENKINS_OPTS", value: "--prefix=/jenkins" } + - name: "hephaestus.next" + ip: "10.88.1.0" + location: "/jenkins.next" + state: "stopped" + enable: "no" + readwrite_volumes: + - { src: "/home/jenkins/next", dest: "/var/jenkins_home" } + readonly_volumes: + - { src: "/home/jenkins/.ssh", dest: "/var/jenkins_home/.ssh" } + - { src: "/home/jenkins/.netrc", dest: "/var/jenkins_home/.netrc" } + - { src: "/home/jenkins/.gitconfig", dest: "/var/jenkins_home/.gitconfig" } + add_hosts: + - { src: "podman", ip: "10.88.0.3" } + - { src: "server", ip: "10.88.0.2" } + ports_mapping: + - { src: "8080", dest: "8180" } + vars: + - { name: "JENKINS_OPTS", value: "--prefix=/jenkins.next" } +instance: + url: "http://example.jenkins.server" +mailer: + replyTo: "no-reply@example.com" + smtp: + host: "smtp.example.com" + port: "587" diff --git a/molecule/jenkins_casc_check/verify.yml b/molecule/jenkins_casc_check/verify.yml new file mode 100644 index 0000000..65b69e7 --- /dev/null +++ b/molecule/jenkins_casc_check/verify.yml @@ -0,0 +1,10 @@ +--- +- name: Verify generated casc.yml + hosts: all + gather_facts: false + tasks: + - name: Ensure casc.yml is valid YAML + shell: "python3 -c 'import yaml, sys; yaml.safe_load(sys.stdin)' < /tmp/casc_generated.yaml" + register: yaml_check + failed_when: yaml_check.rc != 0 + changed_when: false diff --git a/roles/jenkins/templates/casc.yaml.j2 b/roles/jenkins/templates/casc.yaml.j2 index b14c631..5a8b3b4 100644 --- a/roles/jenkins/templates/casc.yaml.j2 +++ b/roles/jenkins/templates/casc.yaml.j2 @@ -125,44 +125,60 @@ jenkins: - id: {{ jenkins.admin.id }} password: {{ jenkins.admin.password }} {% endif %} -{% if jenkins.view.tabs is defined %} - views: +{% if jenkins.view is defined %} +views: - all: name: "all" - - - dashboard: - name: "cryo" +{% for view in jenkins.view %} + - list: + name: "{{ view.name }}" columns: -{% for col in jenkins.view.tabs.columns %} - - "{{ col }}" -{% endfor %} - includeStdJobList: true + - "status" + - "weather" + - "jobName" + - "lastSuccess" + - "lastFailure" + - "lastDuration" + - "buildButton" +{% if view.includeRegex is defined%} + includeRegex: "{{ view.includeRegex }}" +{% endif %} +{% if view.excludeRegex is defined%} + excludeRegex: "{{ view.excludeRegex }}" +{% endif %} +{% if view.jobNames is defined%} jobNames: - includeRegex: "cryo-.*" - - - dashboard: +{% for jobName in view.jobNames %} + - "{{ jobName }}" +{% endfor %} +{% endif %} +{% endfor %} + - list: name: "Failing Jobs" columns: -{% for col in jenkins.view.tabs.columns %} - - "{{ col }}" -{% endfor %} - includeStdJobList: true + - "status" + - "weather" + - "jobName" + - "lastSuccess" + - "lastFailure" + - "lastDuration" + - "buildButton" + jobNames: [] jobFilters: - - jobStatusFilter: - aborted: false - disabled: false - failed: true - includeExcludeTypeString: "includeMatched" - stable: false - unstable: false - - jobStatusFilter: - aborted: false - disabled: true - failed: false - includeExcludeTypeString: "excludeMatched" - stable: false - unstable: false - viewsTabBar: "standard" + - jobStatusFilter: + aborted: false + disabled: false + failed: true + includeExcludeTypeString: "includeMatched" + stable: false + unstable: false + - jobStatusFilter: + aborted: false + disabled: true + failed: false + includeExcludeTypeString: "excludeMatched" + stable: false + unstable: false {% endif %} security: @@ -194,4 +210,3 @@ unclassified: jobs: - url: "https://raw.githubusercontent.com/jboss-set/cedalion/main/job-configurator.groovy" - script: "queue('job-configurator')" - diff --git a/roles/jenkins/vars/main.yml b/roles/jenkins/vars/main.yml index 24b900b..acd4fb6 100644 --- a/roles/jenkins/vars/main.yml +++ b/roles/jenkins/vars/main.yml @@ -45,6 +45,61 @@ jenkins: group: "{{ jenkins_role_user_group }}" desc: "{{ jenkins_role_user_desc }}" view: + - name: "Ansible AMQ Broker" + includeRegex: ".*amq.*" + - name: "Ansible CI" + includeRegex: "ansible-ci-.*" + - name: "Ansible DOT" + includeRegex: "ansible-downstream-tests-.*" + - name: "Ansible Demos" + includeRegex: ".*-demo" + - name: "Ansible Downstream CI" + includeRegex: "ansible-downstream-ci-.*" + - name: "Ansible Downstream Runner" + includeRegex: "ansible-downstream-runner-.*" + - name: "Ansible EAP" + includeRegex: ".*(wildfly|eap).*" + excludeRegex: '.*eap-[0-9]+\\.[0-9]+.*|wildfly-.*' + - name: "Ansible JWS" + includeRegex: ".*jws.*" + - name: "Ansible Janus" + includeRegex: "ansible-janus-.*" + - name: "Ansible Quarkus" + includeRegex: ".*quarkus.*" + - name: "Ansible Release" + includeRegex: "ansible-release-.*" + - name: "Component Alignment" + includeRegex: "component-alignment-.*" + - name: "SET CI" + includeRegex: "ci-.*" + - name: "eap-6.4.x" + includeRegex: 'eap-6\\.4\\.x-.*' + - name: "eap-7.0.x" + includeRegex: 'eap-7\\.0\\.x-.*' + - name: "eap-7.1.x" + includeRegex: 'eap-7\\.1\\.x-.*' + - name: "eap-7.2.x" + includeRegex: 'eap-7\\.2\\.x-.*' + - name: "eap-7.3.x" + includeRegex: 'eap-7\\.3\\.x-.*' + - name: "eap-7.4.x" + includeRegex: 'eap-7\\.4\\.x-.*' + - name: "eap-8.0.x" + includeRegex: 'eap-8\\.0\\.x-.*' + - name: "vbe" + includeRegex: "vbe-eap-.*" + - name: "vbe-wildfly" + includeRegex: "vbe-wildfly-.*" + - name: "wildfly" + includeRegex: "wildfly-.*" + - name: "xp-2.0.x" + includeRegex: 'xp-2\\.0\\.x-.*' + - name: "xp-3.0.x" + includeRegex: 'xp-3\\.0\\.x-.*' + - name: "xp-4.0.x" + includeRegex: 'xp-4\\.0\\.x-.*' + - name: "cryo" + includeRegex: "cryo-.*" service: - name: hephaestus ip: "{{ known_hosts.jenkins.ip }}"