Skip to content

Commit 72d5024

Browse files
authored
adding qemu/libvirt support (#103)
* adding qemu * appeasing pylint * ran through black linter * Feat/parallelize builds (#102) * attempting to use matrix * fixed matrix... * removing duplicate code * adding build for qemu as well * fixing for linting * adding ufw allow for libvirt network * adding context with messages sent * fixing packer script wrapper to handle qemu * appeasing shfmt
1 parent 060985b commit 72d5024

File tree

8 files changed

+499
-299
lines changed

8 files changed

+499
-299
lines changed

.circleci/config.yml

Lines changed: 42 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -320,22 +320,11 @@ jobs:
320320
pipenv run python --version
321321
- run-black_linter
322322

323-
packer-linting_vbox:
324-
docker:
325-
- image: 'hashicorp/packer:light'
326-
steps:
327-
- attach_workspace:
328-
at: /tmp/packer_workspace
329-
- checkout
330-
- submodule-sync
331-
- run: cp -v /tmp/packer_workspace/* .
332-
- run: packer version
333-
- packer-lint:
334-
template-file: kali-template.json
335-
vars-file: variables.json
336-
only-builder: virtualbox-iso
337-
338-
packer-linting_vmware:
323+
packer-linting:
324+
parameters:
325+
hypervisor:
326+
description: hypervisor to validate
327+
type: string
339328
docker:
340329
- image: 'hashicorp/packer:light'
341330
steps:
@@ -348,22 +337,8 @@ jobs:
348337
- packer-lint:
349338
template-file: kali-template.json
350339
vars-file: variables.json
351-
only-builder: vmware-iso
340+
only-builder: '<< parameters.hypervisor >>'
352341

353-
packer-linting_aws:
354-
docker:
355-
- image: 'hashicorp/packer:light'
356-
steps:
357-
- attach_workspace:
358-
at: /tmp/packer_workspace
359-
- checkout
360-
- submodule-sync
361-
- run: cp -v /tmp/packer_workspace/* .
362-
- run: packer version
363-
- packer-lint:
364-
template-file: templates/template.json
365-
vars-file: templates/example-variables.json
366-
only-builder: amazon-ebs
367342

368343
terraform-linting:
369344
# executor: terraform/default
@@ -373,7 +348,7 @@ jobs:
373348
- run: terraform --version
374349
# linting the packet terraform files
375350
- terraform-lint:
376-
code-path: ci/packet_terraform-cloud
351+
code-path: ci/packet_terraform-cloud-build_all
377352
# linting the aws terraform files
378353
# - terraform-lint:
379354
# code-path: ci/kali_aws_info
@@ -493,7 +468,7 @@ jobs:
493468
steps:
494469
- run: terraform --version
495470
- terraform-deploy:
496-
code-path: ci/packet_terraform-cloud
471+
code-path: ci/packet_terraform-cloud-build_all
497472

498473

499474
terraform-packet_destroy:
@@ -502,7 +477,7 @@ jobs:
502477
steps:
503478
- run: terraform --version
504479
- terraform-destroy:
505-
code-path: ci/packet_terraform-cloud
480+
code-path: ci/packet_terraform-cloud-build_all
506481

507482
ansible-bootstrap:
508483
docker:
@@ -520,6 +495,10 @@ jobs:
520495
ansible-packer_build:
521496
docker:
522497
- image: 'elrey741/ansible-playbook_packet:alpine'
498+
parameters:
499+
build:
500+
description: build target for packer to hit
501+
type: string
523502
steps:
524503
- ansible-prep
525504
- add_ssh_keys:
@@ -538,7 +517,7 @@ jobs:
538517
command: |
539518
ansible-playbook -i ci/scripts/packet_net.py -u root \
540519
-e "api_key_from_env=${TEXTBELT_KEY:-} phone_from_env=${PERSONAL_NUM:-}" \
541-
-e CIRCLECI="${CIRCLECI:-}" ci/packer_build.yml
520+
-e CIRCLECI="${CIRCLECI:-}" ci/packer_build.yml --limit="packer-build-box-<< parameters.build >>"
542521
- run: |
543522
mkdir -p /tmp/artifacts
544523
pwd && ls
@@ -567,18 +546,10 @@ workflows:
567546
- ansible-linting
568547
- generate-packer-file
569548
- generate-packer-vars
570-
- packer-linting_vbox:
571-
requires:
572-
- generate-packer-vars
573-
- generate-packer-file
574-
- shellcheck-warning
575-
- shfmt-linting
576-
- terraform-linting
577-
- markdown-linting
578-
- gh_issues-linting
579-
- python-linting
580-
- ansible-linting
581-
- packer-linting_vmware:
549+
- packer-linting:
550+
matrix:
551+
parameters:
552+
hypervisor: [ "virtualbox-iso", "vmware-iso", "qemu" ]
582553
requires:
583554
- generate-packer-vars
584555
- generate-packer-file
@@ -591,12 +562,14 @@ workflows:
591562
- ansible-linting
592563
- terraform-packet_deploy:
593564
requires:
594-
- packer-linting_vbox
595-
- packer-linting_vmware
565+
- packer-linting
596566
- ansible-bootstrap:
597567
requires:
598568
- terraform-packet_deploy
599569
- ansible-packer_build:
570+
matrix:
571+
parameters:
572+
build: [ "v", "qemu" ]
600573
requires:
601574
- ansible-bootstrap
602575
- terraform-packet_destroy:
@@ -659,11 +632,10 @@ workflows:
659632
ignore:
660633
- master
661634
- dev-stage
662-
- packer-linting_vbox:
663-
requires:
664-
- generate-packer-vars
665-
- generate-packer-file
666-
- packer-linting_vmware:
635+
- packer-linting:
636+
matrix:
637+
parameters:
638+
hypervisor: [ "virtualbox-iso", "vmware-iso", "qemu" ]
667639
requires:
668640
- generate-packer-vars
669641
- generate-packer-file
@@ -715,18 +687,10 @@ workflows:
715687
branches:
716688
only:
717689
- master
718-
- packer-linting_vbox:
719-
requires:
720-
- generate-packer-vars
721-
- generate-packer-file
722-
- shellcheck-warning
723-
- shfmt-linting
724-
- terraform-linting
725-
- markdown-linting
726-
- gh_issues-linting
727-
- python-linting
728-
- ansible-linting
729-
- packer-linting_vmware:
690+
- packer-linting:
691+
matrix:
692+
parameters:
693+
hypervisor: [ "virtualbox-iso", "vmware-iso", "qemu" ]
730694
requires:
731695
- generate-packer-vars
732696
- generate-packer-file
@@ -739,12 +703,14 @@ workflows:
739703
- ansible-linting
740704
- terraform-packet_deploy:
741705
requires:
742-
- packer-linting_vbox
743-
- packer-linting_vmware
706+
- packer-linting
744707
- ansible-bootstrap:
745708
requires:
746709
- terraform-packet_deploy
747710
- ansible-packer_build:
711+
matrix:
712+
parameters:
713+
build: [ "v", "qemu" ]
748714
requires:
749715
- ansible-bootstrap
750716
- terraform-packet_destroy:
@@ -801,18 +767,10 @@ workflows:
801767
branches:
802768
only:
803769
- dev-stage
804-
- packer-linting_vbox:
805-
requires:
806-
- generate-packer-vars
807-
- generate-packer-file
808-
- shellcheck-warning
809-
- shfmt-linting
810-
- terraform-linting
811-
- markdown-linting
812-
- gh_issues-linting
813-
- python-linting
814-
- ansible-linting
815-
- packer-linting_vmware:
770+
- packer-linting:
771+
matrix:
772+
parameters:
773+
hypervisor: [ "virtualbox-iso", "vmware-iso", "qemu" ]
816774
requires:
817775
- generate-packer-vars
818776
- generate-packer-file
@@ -825,12 +783,14 @@ workflows:
825783
- ansible-linting
826784
- terraform-packet_deploy:
827785
requires:
828-
- packer-linting_vbox
829-
- packer-linting_vmware
786+
- packer-linting
830787
- ansible-bootstrap:
831788
requires:
832789
- terraform-packet_deploy
833790
- ansible-packer_build:
791+
matrix:
792+
parameters:
793+
build: [ "v", "qemu" ]
834794
requires:
835795
- ansible-bootstrap
836796
- terraform-packet_destroy:

ci/bootstrap.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@
6464
interface: 'vmnet8'
6565
comment: 'for vmware builder'
6666

67+
- name: adding vmware access through ufw
68+
ufw:
69+
# rule: limit
70+
# setting it to this for now
71+
rule: allow
72+
proto: any
73+
direction: 'in'
74+
interface: 'virbr0'
75+
comment: 'for libvirt builder'
76+
6777
- name: enabling ufw
6878
ufw:
6979
state: enabled

ci/packer_build.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,37 @@
3434
vars:
3535
api_key: '{{ api_key_from_env }}'
3636
phone_number: '{{ phone_from_env }}'
37-
message_contents: 'starting build'
37+
message_contents: 'starting build: {{ ansible_hostname }}'
3838
when: (( api_key_from_env is defined ) and ( api_key_from_env | length > 0 )) and
3939
((phone_from_env is defined ) and ( phone_from_env | length > 0 ))
4040

4141
- name: initial upload to vagrant cloud
4242
block:
4343

44+
- name: setting provider string for vbox & vmware
45+
set_fact:
46+
provider_string: 'virtualbox-iso|vmware-iso'
47+
when: ansible_hostname == 'packer-build-box-v'
48+
49+
- name: setting provider string for qemu
50+
set_fact:
51+
provider_string: 'qemu'
52+
when: ansible_hostname == 'packer-build-box-qemu'
53+
4454
- name: launching the packer build process
4555
script:
4656
cmd: "{{ local_ci_scripts_dir }}/packer_build-wrapper.sh '{{ provider_string }}'"
4757
chdir: '{{ kali_project_folder }}'
4858
args:
4959
creates: '{{ kali_project_folder }}/packer_build.log'
50-
vars:
51-
provider_string: 'virtualbox-iso|vmware-iso'
5260

5361
- name: sending last text message for end
5462
import_role:
5563
name: elreydetoda.textbelt
5664
vars:
5765
api_key: '{{ api_key_from_env }}'
5866
phone_number: '{{ phone_from_env }}'
59-
message_contents: 'finished successfuly, and ending build'
67+
message_contents: 'finished successfuly, and ending build: {{ ansible_hostname }}'
6068
when: (( api_key_from_env is defined ) and ( api_key_from_env | length > 0 )) and
6169
((phone_from_env is defined ) and ( phone_from_env | length > 0 ))
6270

@@ -68,7 +76,7 @@
6876
vars:
6977
api_key: '{{ api_key_from_env }}'
7078
phone_number: '{{ phone_from_env }}'
71-
message_contents: 'build failed (probably upload), but trying to upload with curl script'
79+
message_contents: 'build failed (probably upload), but trying to upload with curl script: {{ ansible_hostname }}'
7280
when: (( api_key_from_env is defined ) and ( api_key_from_env | length > 0 )) and
7381
((phone_from_env is defined ) and ( phone_from_env | length > 0 ))
7482

@@ -95,7 +103,7 @@
95103
vars:
96104
api_key: '{{ api_key_from_env }}'
97105
phone_number: '{{ phone_from_env }}'
98-
message_contents: 'finished successfuly, and ending build'
106+
message_contents: 'finished successfuly, and ending build: {{ ansible_hostname }}'
99107
when: (( api_key_from_env is defined ) and ( api_key_from_env | length > 0 )) and
100108
((phone_from_env is defined ) and ( phone_from_env | length > 0 ))
101109

@@ -107,7 +115,7 @@
107115
vars:
108116
api_key: '{{ api_key_from_env }}'
109117
phone_number: '{{ phone_from_env }}'
110-
message_contents: "didn't complete properly, and ending build"
118+
message_contents: "didn't complete properly, and ending build: {{ ansible_hostname }}"
111119
when: (( api_key_from_env is defined ) and ( api_key_from_env | length > 0 )) and
112120
((phone_from_env is defined ) and ( phone_from_env | length > 0 ))
113121

ci/packet_terraform-cloud-build_all/.terraform.lock.hcl

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)