Skip to content

Commit

Permalink
Refactoring sonarqube issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sbylica-splunk committed Feb 3, 2025
1 parent f090969 commit 68267ec
Show file tree
Hide file tree
Showing 117 changed files with 1,058 additions and 492 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/cd-baremtal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ jobs:
name: Produce BYOE package
run: |
pip3 install poetry
poetry export --without-hashes >package/etc/requirements.txt
poetry self add poetry-plugin-export
poetry export --without-hashes >package/etc/requirements.txt
tar rvf /tmp/baremetal.tar -C package/etc .
tar rvf /tmp/baremetal.tar -C . pyproject.toml
tar rvf /tmp/baremetal.tar -C . poetry.lock
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-lite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
with:
semantic_version: 18
extra_plugins: |
@semantic-release/exec
@semantic-release/exec@v6.0.3
@semantic-release/git
semantic-release-helm
@google/[email protected]
Expand All @@ -86,7 +86,7 @@ jobs:
type=ref,event=tag
- name: matrix
id: matrix
uses: splunk/addonfactory-test-matrix-action@v2.1.9
uses: splunk/addonfactory-test-matrix-action@v3.0.0

security-fossa-scan:
continue-on-error: true
Expand Down Expand Up @@ -430,7 +430,7 @@ jobs:
with:
semantic_version: 18
extra_plugins: |
@semantic-release/exec
@semantic-release/exec@v6.0.3
@semantic-release/git
semantic-release-helm
@google/[email protected]
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/ci-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ jobs:
with:
semantic_version: 18
extra_plugins: |
@semantic-release/exec
@semantic-release/exec@v6.0.3
@semantic-release/git
semantic-release-helm
@google/[email protected]
[email protected]
dry_run: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUNNER_DEBUG: 1
- name: Docker meta
id: docker_action_meta
uses: docker/metadata-action@v5
Expand All @@ -86,7 +87,7 @@ jobs:
type=ref,event=tag
- name: matrix
id: matrix
uses: splunk/addonfactory-test-matrix-action@v2.1.9
uses: splunk/addonfactory-test-matrix-action@v3.0.0

security-fossa-scan:
continue-on-error: true
Expand Down Expand Up @@ -456,7 +457,7 @@ jobs:
with:
semantic_version: 18
extra_plugins: |
@semantic-release/exec
@semantic-release/exec@v6.0.3
@semantic-release/git
semantic-release-helm
@google/[email protected]
Expand Down
13 changes: 7 additions & 6 deletions ansible/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# install requirements in venv
FROM python:3.10 AS venv_builder
RUN pip install ansible~=6.1.0 --no-cache-dir
RUN pip install pywinrm>=0.4.2 --no-cache-dir
RUN pip install ansible-lint>=6.0.0 --no-cache-dir
RUN pip install ansible~=6.1.0 --no-cache-dir \
&& pip install pywinrm>=0.4.2 --no-cache-dir \
&& pip install ansible-lint>=6.0.0 --no-cache-dir

WORKDIR /opt
COPY ./ansible .
COPY ./charts .

RUN apt-get update -y
RUN apt-get install parallel -y
RUN apt-get install sshpass
RUN apt update -y \
&& apt install --no-install-recommends -y build-essential parallel \
&& apt install --no-install-recommends -y sshpass \
&& apt clean

ENV ANSIBLE_CONFIG /opt/ansible.cfg
ENV ANSIBLE_HOST_KEY_CHECKING False
27 changes: 14 additions & 13 deletions ansible/app/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
version: "3.7"
services:
sc4s:
Expand All @@ -7,18 +8,18 @@ services:
condition: on-failure
image: ghcr.io/splunk/splunk-connect-for-syslog/container3:latest
ports:
- target: 514
published: 514
protocol: tcp
- target: 514
published: 514
protocol: udp
- target: 601
published: 601
protocol: tcp
- target: 6514
published: 6514
protocol: tcp
- target: 514
published: 514
protocol: tcp
- target: 514
published: 514
protocol: udp
- target: 601
published: 601
protocol: tcp
- target: 6514
published: 6514
protocol: tcp
env_file:
- /opt/sc4s/env_file
volumes:
Expand All @@ -30,4 +31,4 @@ services:
# - /opt/sc4s/tls:/etc/syslog-ng/tls:z

volumes:
splunk-sc4s-var:
splunk-sc4s-var:
2 changes: 1 addition & 1 deletion ansible/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
## SPDX-License-Identifier: LicenseRef-Splunk-8-2021
##
##
---
version: "3.7"
services:

ansible_sc4s:
build:
context: ../
Expand Down
3 changes: 2 additions & 1 deletion ansible/inventory/inventory.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
all:
hosts:
children:
node:
hosts:
node_1:
ansible_host:
ansible_host:
1 change: 1 addition & 0 deletions ansible/inventory/inventory_microk8s.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
all:
hosts:
children:
Expand Down
1 change: 1 addition & 0 deletions ansible/inventory/inventory_microk8s_ha.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
all:
hosts:
children:
Expand Down
1 change: 1 addition & 0 deletions ansible/inventory/inventory_swarm.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
all:
hosts:
children:
Expand Down
2 changes: 1 addition & 1 deletion ansible/playbooks/docker.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- hosts: node_1
become: yes
become: true
vars:
iface: "{{ swarm_iface | default('eth0') }}"
tasks:
Expand Down
8 changes: 4 additions & 4 deletions ansible/playbooks/docker_swarm.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- hosts: manager[0]
become: yes
become: true
vars:
iface: "{{ swarm_iface | default('eth0') }}"
tasks:
Expand All @@ -10,7 +10,7 @@
- include_tasks: ../tasks/docker_swarm/create_swarm.yml

- hosts: manager, !manager[0]
become: yes
become: true
vars:
iface: "{{ swarm_iface | default('eth0') }}"
tasks:
Expand All @@ -20,14 +20,14 @@
- include_tasks: ../tasks/docker_swarm/join_managers.yml

- hosts: worker
become: yes
become: true
tasks:
- name: Docker installation role
include_role:
name: install_docker
- include_tasks: ../tasks/docker_swarm/join_workers.yml

- hosts: manager[0]
become: yes
become: true
tasks:
- include_tasks: ../tasks/docker_swarm/deploy_stack.yml
5 changes: 3 additions & 2 deletions ansible/playbooks/microk8s.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
- hosts: node_1
become: yes
become: true
vars:
microk8s_plugins:
# Do not provide here metallb here as the installation process is different to standard plugins
# Do not provide here metallb here as the installation process
# is different to standard plugins
helm3: true
dns: true
community: true
Expand Down
10 changes: 6 additions & 4 deletions ansible/playbooks/microk8s_ha.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
- hosts: manager
become: yes
become: true
vars:
microk8s_plugins:
# Do not provide here metallb here as the installation process is different to standard plugins
# Do not provide here metallb here as the installation process
# is different to standard plugins
helm3: true
dns: true
community: true
Expand All @@ -19,10 +20,11 @@
- include_tasks: ../tasks/mk8s/update_etc_hosts.yml

- hosts: workers
become: yes
become: true
vars:
microk8s_plugins:
# Do not provide here metallb here as the installation process is different to standard plugins
# Do not provide here metallb here as the installation process
# is different to standard plugins
helm3: true
dns: true
community: true
Expand Down
2 changes: 1 addition & 1 deletion ansible/playbooks/podman.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- hosts: node_1
become: yes
become: true
tasks:
- name: Podman installation role
include_role:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Ensure dependencies are installed
apt:
update-cache: yes
update-cache: true
name:
- ca-certificates
- curl
Expand Down
5 changes: 3 additions & 2 deletions ansible/roles/install_docker/tasks/install_docker_rhel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
- name: Add Docker Repository (RedHat, centOS)
shell: |
dnf install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --add-repo
https://download.docker.com/linux/centos/docker-ce.repo
args:
warn: no
warn: false

- name: Install docker-ce (RedHat, CentOS)
yum:
Expand Down
11 changes: 5 additions & 6 deletions ansible/tasks/docker/deploy_app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
file:
path: "{{ item }}"
state: directory
mode: 0755
mode: 0750
loop:
- /opt/sc4s
- /opt/sc4s/tls
Expand All @@ -16,15 +16,15 @@
dest: "/lib/systemd/system/sc4s.service"
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: u=rw,g=rw,o=r
mode: u=rw,g=rw

- name: Copying env_file file on the server
copy:
src: "/opt/ansible/resources/env_file"
dest: "/opt/sc4s/env_file"
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: u=rw,g=rw,o=r
mode: u=rw,g=rw

- name: Create a volume
docker_volume:
Expand All @@ -33,7 +33,6 @@
- name: Enable sc4s service
ansible.builtin.systemd:
name: sc4s
enabled: yes
daemon_reload: yes
enabled: true
daemon_reload: true
state: started

2 changes: 1 addition & 1 deletion ansible/tasks/docker_swarm/create_swarm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@

- name: "set fact: join_token_worker"
set_fact:
join_token_worker: "{{ join_token_worker_command['stdout'] }}"
join_token_worker: "{{ join_token_worker_command['stdout'] }}"
7 changes: 3 additions & 4 deletions ansible/tasks/docker_swarm/deploy_stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
dest: "/home/{{ ansible_user }}/docker-compose.yml"
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: u=rw,g=rw,o=r
mode: u=rw,g=rw

- name: Create sc4s dependency directories
file:
path: "{{ item }}"
state: directory
mode: 0755
mode: 0750
loop:
- /opt/sc4s
- /opt/sc4s/tls
Expand All @@ -24,7 +24,7 @@
dest: "/opt/sc4s/env_file"
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: u=rw,g=rw,o=r
mode: u=rw,g=rw

- name: Create a volume
docker_volume:
Expand All @@ -36,4 +36,3 @@
name: SC4S
compose:
- "/home/{{ ansible_user }}/docker-compose.yml"

5 changes: 3 additions & 2 deletions ansible/tasks/docker_swarm/join_managers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

- name: v2
add_host:
hostname: "{{ groups['manager'] | map('extract', hostvars, ['ansible_host']) | join(':2377,') }}:2377"
hostname: "{{ groups['manager'] |
map('extract', hostvars, ['ansible_host']) | join(':2377,') }}:2377"
groups: main_nodes_ips_with_port
with_items: "{{ ansible_play_hosts | default(play_hosts) }}"

Expand All @@ -17,4 +18,4 @@
state: join
timeout: 60
join_token: "{{ hostvars[first_swarm_manager_host].join_token_manager }}"
remote_addrs: "{{ groups['main_nodes_ips_with_port'][0] }}:2377"
remote_addrs: "{{ groups['main_nodes_ips_with_port'][0] }}:2377"
5 changes: 3 additions & 2 deletions ansible/tasks/docker_swarm/join_workers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

- name: v2
add_host:
hostname: "{{ groups['manager'] | map('extract', hostvars, ['ansible_host']) | join(':3000,') }}:3000"
hostname: "{{ groups['manager'] | map('extract', hostvars,
['ansible_host']) | join(':3000,') }}:3000"
groups: main_nodes_ips_with_port
with_items: "{{ ansible_play_hosts | default(play_hosts) }}"

Expand All @@ -14,4 +15,4 @@
state: join
timeout: 60
join_token: "{{ hostvars[first_swarm_manager_host].join_token_worker }}"
remote_addrs: "{{ groups['main_nodes_ips_with_port'][0] }}:2377"
remote_addrs: "{{ groups['main_nodes_ips_with_port'][0] }}:2377"
Loading

0 comments on commit 68267ec

Please sign in to comment.