Skip to content

Commit d7668af

Browse files
committed
chore: fix multiple linting issues
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
1 parent f1b672b commit d7668af

File tree

11 files changed

+111
-107
lines changed

11 files changed

+111
-107
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Main CI
22
on:
33
push:
4-
branches:
4+
branches:
55
- main
66
paths:
77
- 'images/**'

.github/workflows/matrix-gen-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
steps:
1111
- name: Checkout repo ⤵️
1212
uses: actions/checkout@v4
13-
13+
1414
- name: Build matrix_gen
1515
working-directory: ./matrix_gen
1616
run: go build .

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: PR CI
22
on:
33
pull_request:
4-
branches:
4+
branches:
55
- main
66
paths:
77
- 'images/**'

.github/workflows/reusable_build_images.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Build and Push docker images
22
on:
3-
workflow_call:
3+
workflow_call:
44
inputs:
55
version:
66
description: 'docker images version to be built/tagged'
@@ -26,7 +26,7 @@ jobs:
2626
matrix:
2727
arch: [amd64, arm64]
2828
runs-on: ${{ (matrix.arch == 'arm64' && 'ubuntu-22.04-arm') || 'ubuntu-22.04' }}
29-
steps:
29+
steps:
3030
- name: Checkout repo
3131
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3232

@@ -42,12 +42,12 @@ jobs:
4242
if: inputs.push
4343
run: |
4444
echo "PUSH=true" >> $GITHUB_ENV
45-
45+
4646
- name: Set LATEST env var
4747
if: inputs.is_latest
4848
run: |
4949
echo "LATEST=true" >> $GITHUB_ENV
50-
50+
5151
- name: Set TAG env var
5252
run: |
5353
echo "TAG=${{ inputs.version }}" >> $GITHUB_ENV

action.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ inputs:
1010
description: 'libs repo to be tested, eg: falcosecurity/libs'
1111
required: false
1212
default: 'falcosecurity/libs'
13-
build_matrix:
13+
build_matrix:
1414
description: 'Whether to generate matrixes as matrix artifact'
1515
required: false
1616
default: 'false'
@@ -24,7 +24,7 @@ outputs:
2424
value: ${{ steps.store-outputs.outputs.ansible }}
2525
matrix_output:
2626
description: "Uploaded matrix artifact name"
27-
value: ${{ steps.store-outputs.outputs.matrix }}
27+
value: ${{ steps.store-outputs.outputs.matrix }}
2828

2929
runs:
3030
using: "composite"
@@ -47,7 +47,7 @@ runs:
4747
working-directory: ${{ github.action_path }}/ansible-playbooks
4848
shell: bash
4949
run: ansible-playbook bootstrap.yml --extra-vars "@vars.yml"
50-
50+
5151
- name: Common setup
5252
working-directory: ${{ github.action_path }}/ansible-playbooks
5353
shell: bash
@@ -57,38 +57,38 @@ runs:
5757
working-directory: ${{ github.action_path }}/ansible-playbooks
5858
shell: bash
5959
run: ansible-playbook git-repos.yml --extra-vars "@vars.yml"
60-
60+
6161
- name: Run scap-open tests
6262
working-directory: ${{ github.action_path }}/ansible-playbooks
6363
shell: bash
6464
run: |
65-
ansible-playbook scap-open.yml --extra-vars "@vars.yml" || :
66-
65+
ansible-playbook scap-open.yml --extra-vars "@vars.yml" || :
66+
6767
- name: Tar output files
6868
shell: bash
6969
run: tar -cvf $GITHUB_ACTION_PATH/ansible_output.tar ~/ansible_output_${{ github.run_id }}
70-
70+
7171
- name: Build matrix_gen and generate matrix
7272
if: inputs.build_matrix == 'true'
7373
working-directory: ${{ github.action_path }}/matrix_gen
7474
env:
7575
GOPATH: /root/go
7676
GOCACHE: /root/.cache/go-build
77-
shell: bash
77+
shell: bash
7878
run: |
7979
go build .
8080
./matrix_gen --root-folder ~/ansible_output_${{ github.run_id }} --output-file matrix.md
81-
81+
8282
- name: Set output
8383
id: store-outputs
8484
shell: bash
8585
run: |
8686
echo "ansible=${{ github.action_path }}/ansible_output.tar" >> $GITHUB_OUTPUT
87-
echo "matrix=${{ github.action_path }}/matrix_gen/matrix.md" >> $GITHUB_OUTPUT
88-
87+
echo "matrix=${{ github.action_path }}/matrix_gen/matrix.md" >> $GITHUB_OUTPUT
88+
8989
- name: Cleanup
9090
if: always()
9191
working-directory: ${{ github.action_path }}/ansible-playbooks
9292
shell: bash
9393
run: |
94-
ansible-playbook clean-up.yml --extra-vars "@vars.yml" || :
94+
ansible-playbook clean-up.yml --extra-vars "@vars.yml" || :

ansible-playbooks/group_vars/all/vars.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,4 @@ remote_repos_folder: "/root"
9898
cached_files_path: "/root/kernel_testing_ci_cache"
9999

100100
# Directory where ephemeral, run-specific files are stored.
101-
runtime_root: "{{ playbook_dir }}/runtime"
101+
runtime_root: "{{ playbook_dir }}/runtime"

ansible-playbooks/roles/bootstrap/tasks/main.yml

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727

2828
- name: Set run files directory for the current run run_id={{ run_id }}
2929
ansible.builtin.set_fact:
30-
run_files_path: "{{ runtime_root }}/{{ run_id }}"
30+
bootstrap_run_files_path: "{{ runtime_root }}/{{ run_id }}"
3131

3232
- name: Create the run files directory run_id={{ run_id }}
3333
ansible.builtin.file:
34-
path: "{{ run_files_path }}"
34+
path: "{{ bootstrap_run_files_path }}"
3535
state: directory
3636
mode: '0755'
3737

@@ -108,11 +108,11 @@
108108
ansible.builtin.shell: |
109109
# Enable Bash safety only if running under Bash.
110110
[ -n "$BASH_VERSION" ] && eval "set -eo pipefail"
111-
111+
112112
CID=""
113113
TMP_DIR=""
114114
LOOPDEV=""
115-
115+
116116
cleanup() {
117117
EXIT_STATUS=$?
118118
[ "$EXIT_STATUS" -ne 0 ] && rm -rf "{{ disk_image }}" || :
@@ -123,27 +123,27 @@
123123
rm -rf "$TMP_DIR" || :
124124
fi
125125
}
126-
126+
127127
# Trigger cleanup at exit.
128128
trap cleanup EXIT
129-
129+
130130
# Create an initial empty disk image.
131131
truncate -s 5G "{{ disk_image }}"
132132
mkfs.ext4 -F "{{ disk_image }}"
133-
133+
134134
# Create container.
135135
CID=$(docker create "{{ item.rootfs }}" /bin/sh) || exit 1
136-
136+
137137
# Create a temporary directory.
138138
TMP_DIR=$(mktemp -d) || exit 1
139-
139+
140140
# Attach loop device explicitly
141141
LOOPDEV=$(losetup -f --show "{{ disk_image }}")
142142
143143
# Mount disk on a loop device and copy the image content into the disk.
144144
mount -o loop "{{ disk_image }}" "$TMP_DIR"
145145
docker export "$CID" | tar -C "$TMP_DIR" -xf -
146-
146+
147147
# Finalize and check disk integrity.
148148
sync
149149
umount "$TMP_DIR"
@@ -155,7 +155,7 @@
155155
vars:
156156
rootfs_basename: "{{ item.rootfs | basename | regex_replace(':', '.') }}"
157157
original_image: "{{ cached_files_path }}/{{ rootfs_basename }}.ext4"
158-
working_image: "{{ run_files_path }}/{{ rootfs_basename }}.ext4"
158+
working_image: "{{ bootstrap_run_files_path }}/{{ rootfs_basename }}.ext4"
159159
# Create a lightweight CoW clone (if fs supports reflinks) and preserve raw disk sparseness.
160160
ansible.builtin.command: >
161161
cp --sparse=always --reflink=auto "{{ original_image }}" "{{ working_image }}"
@@ -168,7 +168,7 @@
168168
- name: Setup ssh inside rootfs ext4 image clones
169169
vars:
170170
rootfs_basename: "{{ item.rootfs | basename | regex_replace(':', '.') }}"
171-
disk_image: "{{ run_files_path }}/{{ rootfs_basename }}.ext4"
171+
disk_image: "{{ bootstrap_run_files_path }}/{{ rootfs_basename }}.ext4"
172172
become: true
173173
block:
174174
- name: Ensure filesystem is clean before modifying rootfs ext4 image clones
@@ -191,21 +191,22 @@
191191
loop: "{{ machines | union(builders) }}"
192192
when: item.arch == ansible_facts['architecture']
193193

194-
- import_role:
194+
- name: Run common/tasks/compute_tap_dev_map.yml
195+
ansible.builtin.import_role:
195196
name: common
196197
tasks_from: compute_tap_dev_map
197198

198199
- name: Verify any conflict in tap device map
199200
ansible.builtin.command: >
200-
"{{ role_path }}/files/check_net_conflicts.sh" {{ tap_dev_map | to_json | quote }}
201+
"{{ role_path }}/files/check_net_conflicts.sh" {{ common_tap_dev_map | to_json | quote }}
201202
changed_when: false
202203

203204
- name: Create and configure tap devices for VMs
204205
become: true
205206
block:
206207
- name: Create tap devices
207208
vars:
208-
tap_dev_name: "{{ tap_dev_map[item.name].name }}"
209+
tap_dev_name: "{{ common_tap_dev_map[item.name].name }}"
209210
ansible.builtin.command: ip tuntap add dev "{{ tap_dev_name }}" mode tap
210211
args:
211212
creates: "/sys/class/net/{{ tap_dev_name }}/ifindex"
@@ -214,21 +215,22 @@
214215

215216
- name: Set tap devices up
216217
vars:
217-
tap_dev_name: "{{ tap_dev_map[item.name].name }}"
218+
tap_dev_name: "{{ common_tap_dev_map[item.name].name }}"
218219
ansible.builtin.command: ip link set "{{ tap_dev_name }}" up
219220
loop: "{{ machines | union(builders) }}"
220221
when: item.arch == ansible_facts["architecture"]
221222
changed_when: false
222223

223224
- name: Set IP addresses on tap devices
224225
vars:
225-
tap_dev_name: "{{ tap_dev_map[item.name].name }}"
226-
ip_addr: "{{ tap_dev_map[item.name].host_ip }}/30"
227-
ansible.builtin.shell: |
228-
ip -o addr show dev "{{ tap_dev_name }}" | grep -q "{{ ip_addr }}" || \
229-
ip addr add "{{ ip_addr }}" dev "{{ tap_dev_name }}"
226+
tap_dev_name: "{{ common_tap_dev_map[item.name].name }}"
227+
ip_addr: "{{ common_tap_dev_map[item.name].host_ip }}/30"
228+
ansible.builtin.command: ip addr add "{{ ip_addr }}" dev "{{ tap_dev_name }}"
230229
loop: "{{ machines | union(builders) }}"
231-
when: item.arch == ansible_facts["architecture"]
230+
when:
231+
- item.arch == ansible_facts["architecture"]
232+
- ip_addr not in lookup('pipe', 'ip -o addr show dev ' ~ tap_dev_name)
233+
changed_when: true
232234

233235
- name: Start dnsmasq services
234236
become: true
@@ -240,18 +242,16 @@
240242
owner: root
241243
group: root
242244
mode: "0644"
243-
register: unit_file
245+
notify: Reload systemd
244246

245-
- name: Reload systemd units
246-
ansible.builtin.systemd:
247-
daemon_reload: true
248-
when: unit_file.changed
247+
- name: Execute notified systemd reloading handler
248+
ansible.builtin.meta: flush_handlers
249249

250250
- name: Start dnsmasq service on each tap device
251251
vars:
252-
tap_dev_name: "{{ tap_dev_map[item.name].name }}"
253-
host_ip: "{{ tap_dev_map[item.name].host_ip }}"
254-
guest_ip: "{{ tap_dev_map[item.name].guest_ip }}"
252+
tap_dev_name: "{{ common_tap_dev_map[item.name].name }}"
253+
host_ip: "{{ common_tap_dev_map[item.name].host_ip }}"
254+
guest_ip: "{{ common_tap_dev_map[item.name].guest_ip }}"
255255
ansible.builtin.systemd:
256256
name: "dnsmasq-tap@{{ tap_dev_name }}:{{ host_ip }}:{{ guest_ip }}"
257257
state: started
@@ -264,21 +264,21 @@
264264
rootfs_basename: "{{ item.rootfs | basename | regex_replace(':', '.') }}"
265265
vmlinux_path: "{{ cached_files_path }}/{{ kernel_basename }}.vmlinux"
266266
initrd_path: "{{ cached_files_path }}/{{ kernel_basename }}.initrd"
267-
rootfs_disk_path: "{{ run_files_path }}/{{ rootfs_basename }}.ext4"
268-
tap_dev_name: "{{ tap_dev_map[item.name].name }}"
267+
rootfs_disk_path: "{{ bootstrap_run_files_path }}/{{ rootfs_basename }}.ext4"
268+
tap_dev_name: "{{ common_tap_dev_map[item.name].name }}"
269269
ansible.builtin.template:
270270
src: vmconfig.json.j2
271-
dest: "{{ run_files_path }}/{{ item.name }}.json"
271+
dest: "{{ bootstrap_run_files_path }}/{{ item.name }}.json"
272272
mode: '0755'
273273
loop: "{{ machines | union(builders) }}"
274274
when: item.arch == ansible_facts["architecture"]
275275

276276
- name: Create virtual machines run_id={{ run_id }}
277277
vars:
278278
vm_name: "{{ item.name | regex_replace('[.]', '-') }}-{{ run_id }}"
279-
vm_config_path: "{{ run_files_path }}/{{ item.name }}.json"
279+
vm_config_path: "{{ bootstrap_run_files_path }}/{{ item.name }}.json"
280280
vm_socket_path: "/tmp/{{ run_id }}-{{ item.name }}.sock"
281-
vm_logs_path: "{{ run_files_path }}/{{ item.name }}.log"
281+
vm_logs_path: "{{ bootstrap_run_files_path }}/{{ item.name }}.log"
282282
ansible.builtin.shell: >
283283
RUST_LOG=debug nohup firecracker \
284284
--no-seccomp \

ansible-playbooks/roles/bootstrap/templates/inventory.ini.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
[machines]
33
{% for item in machines %}
44
{% if item.arch == ansible_facts["architecture"] %}
5-
{{ item.name }} ansible_host={{ tap_dev_map[item.name].guest_ip }} ansible_ssh_common_args='-o BindInterface={{ tap_dev_map[item.name].name }}' ansible_ssh_private_key_file={{ prv_key_path }}
5+
{{ item.name }} ansible_host={{ common_tap_dev_map[item.name].guest_ip }} ansible_ssh_common_args='-o BindInterface={{ common_tap_dev_map[item.name].name }}' ansible_ssh_private_key_file={{ prv_key_path }}
66
{% endif %}
77
{% endfor %}
88

99
[builders]
1010
{% for item in builders %}
1111
{% if item.arch == ansible_facts["architecture"] %}
12-
{{ item.name }} ansible_host={{ tap_dev_map[item.name].guest_ip }} ansible_ssh_common_args='-o BindInterface={{ tap_dev_map[item.name].name }}' ansible_ssh_private_key_file={{ prv_key_path }}
12+
{{ item.name }} ansible_host={{ common_tap_dev_map[item.name].guest_ip }} ansible_ssh_common_args='-o BindInterface={{ common_tap_dev_map[item.name].name }}' ansible_ssh_private_key_file={{ prv_key_path }}
1313
{% endif %}
1414
{% endfor %}

0 commit comments

Comments
 (0)