Skip to content

Commit d3b7c2a

Browse files
authored
0.0.5 release
* adding legend * fixing logos * circleci config more verbose & more declaritive * fixing exclude to ignore * fixing packer lint dep * adding dev suffix for all dev branches * handling circleci build for dev branches * modularizing python linting & add pylint back * fixing C0301 * fixing W0611, because not used yet * fixing W0612 * fixing W0612 * fixing C0103 * fixing C0116 * fixing C0114 * fixing R0914 & W0511 * moving global disables to pylintrc file * forgot to push config change... 🙃 * smaller instance size * making any facility * adding black python ilnter * extending build time because slower remote server * modularizing ansible linting * adding playbook syntax-check * adding yamllint * adding yamllint fixes * adding go dep for shfmt * adding shfmt deps to vm * fixing path errors * fixing pathing * formatting to shfmt standard - bash * conforming to shfmt styleing - posix * adding shfmt to pipeline checks * adding black python ilnter * modularizing ansible linting * adding playbook syntax-check * adding yamllint * adding yamllint fixes * adding go dep for shfmt * adding shfmt deps to vm * fixing path errors * fixing pathing * formatting to shfmt standard - bash * conforming to shfmt styleing - posix * adding shfmt to pipeline checks * changing instance size for development * formatting for terraform * using orb instead of container * fixing pipeline dep problem * reverting change for packaging * testing out different instance size * removing more filters * linting vmware packer builder * closes #76 * helps if you validate the right template... * Bug/vmware restoration/#75 (#77) * removing more filters * linting vmware packer builder * closes #76 * helps if you validate the right template... * adding vmware support everywhere * passing through license and ufw * enabling vmware packer build * removing uncessary dep for ansible, because of #74 * fixing dependency issue * testing out different instance size * passing env vars
2 parents 74f8e81 + 6b7b7bc commit d3b7c2a

26 files changed

+815
-502
lines changed

.circleci/config.yml

Lines changed: 310 additions & 84 deletions
Large diffs are not rendered by default.

.linting-configs/pylintrc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# copied from https://github.com/PyCQA/pylint/blob/98d2c060ba0dbae6abecff2393cb6dd8a9bde97b/pylintrc
2+
[MESSAGES CONTROL]
3+
4+
# Only show warnings with the listed confidence levels. Leave empty to show
5+
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
6+
confidence=
7+
8+
# Disable the message, report, category or checker with the given id(s). You
9+
# can either give multiple identifiers separated by comma (,) or put this
10+
# option multiple times (only on the command line, not in the configuration
11+
# file where it should appear only once).You can also use "--disable=all" to
12+
# disable everything first and then reenable specific checks. For example, if
13+
# you want to run only the similarities checker, you can use "--disable=all
14+
# --enable=similarities". If you want to run only the classes checker, but have
15+
# no Warning level messages displayed, use"--disable=all --enable=classes
16+
# --disable=W"
17+
18+
disable=
19+
too-many-locals,
20+
fixme,
21+
missing-module-docstring

.linting-configs/yamllint

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
line-length:
6+
max: 120
7+
level: warning
8+
truthy: disable

build.sh_not-working

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
# https://elrey.casa/bash/scripting/harden
44
set -${-//[s]/}eu${DEBUG+xv}o pipefail
55

6-
7-
function main(){
8-
for i in $(grep run .circleci/config.yml | rev | awk '{print $1}' | rev) ; do
6+
function main() {
7+
for i in $(grep run .circleci/config.yml | rev | awk '{print $1}' | rev); do
98
# executing everying script found in circle ci config
109
bash "${i}"
1110
done
1211
}
1312

1413
# https://blog.elreydetoda.site/cool-shell-tricks/#bashscriptingbashsmain
15-
if [[ "${0}" = "${BASH_SOURCE[0]}" ]] ; then
14+
if [[ "${0}" = "${BASH_SOURCE[0]}" ]]; then
1615
main "${@}"
1716
fi

ci/ansible-requirements.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ collections:
77

88
roles:
99
- name: elreydetoda.textbelt
10-
- name: diodonfrost.vagrant
11-
version: 1.5.0
10+
# - name: diodonfrost.vagrant
11+
# version: 1.5.0

ci/bootstrap.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
- hosts: all
33
become: yes
44
collections:
5-
- elreydetoda.virtualization
5+
- elreydetoda.virtualization
66
tasks:
77

88
- name: installation of software
@@ -20,7 +20,7 @@
2020
name: vmware
2121
vars:
2222
vmware_bundle_checksum: ''
23-
# vmware_license_key: ''
23+
vmware_license_key: '{{ vmware_license | default() }}'
2424

2525
- name: installation of kvm
2626
import_role:
@@ -36,16 +36,16 @@
3636
- name: install vagrant
3737
include_role:
3838
# currently not working: https://github.com/elreydetoda/packer-kali_linux/issues/51
39-
# name: vagrant
40-
name: diodonfrost.vagrant
39+
name: vagrant
40+
# name: diodonfrost.vagrant
4141

4242
- name: ufw setup
4343
block:
4444

4545
- name: install ufw
4646
package:
47-
name: ufw
48-
state: present
47+
name: ufw
48+
state: present
4949

5050
- name: adding ssh to allow
5151
ufw:
@@ -54,6 +54,16 @@
5454
rule: allow
5555
name: OpenSSH
5656

57+
- name: adding vmware access through ufw
58+
ufw:
59+
# rule: limit
60+
# setting it to this for now
61+
rule: allow
62+
proto: any
63+
direction: 'in'
64+
interface: 'vmnet8'
65+
comment: 'for vmware builder'
66+
5767
- name: enabling ufw
5868
ufw:
5969
state: enabled

ci/packer_build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343

4444
- name: launching the packer build process
4545
script:
46-
cmd: '{{ local_ci_scripts_dir }}/packer_build-wrapper.sh {{ provider_string }}'
46+
cmd: "{{ local_ci_scripts_dir }}/packer_build-wrapper.sh '{{ provider_string }}'"
4747
chdir: '{{ kali_project_folder }}'
4848
args:
4949
creates: '{{ kali_project_folder }}/packer_build.log'
5050
vars:
51-
provider_string: 'virtualbox-iso'
51+
provider_string: 'virtualbox-iso|vmware-iso'
5252

5353
- name: sending last text message for end
5454
import_role:

ci/packet_terraform-cloud/main.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ variable "server_hostname" {
4646
variable "provision_plan" {
4747
description = "The type of the device (server) getting assigned."
4848
type = string
49-
default = "c3.small.x86"
49+
# default = "baremetal_0"
50+
# DEV
51+
# default = "c3.small.x86"
52+
default = "baremetal_1e"
5053
}
5154

5255
##################################################
@@ -75,10 +78,10 @@ resource "packet_device" "packer_build_server" {
7578
project_id = var.project_id
7679
operating_system = data.packet_operating_system.ubuntu_lts.id
7780
plan = var.provision_plan
78-
# facilities = ["any"]
81+
facilities = ["any"]
7982
# TODO: remove
8083
# added because of failure to provision in SV15 region
81-
facilities = ["dc13", "ny5", "iad2", "dfw2"]
84+
# facilities = ["dc13", "ny5", "iad2", "dfw2"]
8285
billing_cycle = "hourly"
8386

8487
}

ci/scripts/manual_upload.sh

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,31 @@ BASE="$(pwd -P)"
1414
pushd "$(dirname "$0")" > /dev/null
1515
popd > /dev/null
1616

17-
1817
printf '\n\n'
1918

20-
21-
22-
function help(){
19+
function help() {
2320

2421
## outputing help text
25-
printf 'Argument Description:,Script Name,Org Name,Name of box,Provider,Version,File Path\nExample execution:,./%s,double16,linux-dev-workstation,virtualbox,201809.1,box/virtualbox/linux-dev-workstation-201809.1.box\n' "$(basename "${0}")" | column -s ',' -tn
22+
printf 'Argument Description:,Script Name,Org Name,Name of box,Provider,Version,File Path\nExample execution:,./%s,double16,linux-dev-workstation,virtualbox,201809.1,box/virtualbox/linux-dev-workstation-201809.1.box\n' "$(basename "${0}")" | column -s ',' -tn
2623
printf '\nOther Arguments/flags:\n'
2724
printf '\t%s) print this help section\n' '-h|--help'
2825
exit 1
2926

3027
}
3128

32-
function ci_get_vars(){
33-
if [[ -f "${variables_file}" ]] ; then
34-
vm_name="$( grep '"vm_name"' "${variables_file}" | cut -d '"' -f 4 )"
29+
function ci_get_vars() {
30+
if [[ -f "${variables_file}" ]]; then
31+
vm_name="$(grep '"vm_name"' "${variables_file}" | cut -d '"' -f 4)"
3532
ORG="$(cut -d '/' -f 1 <<< "${vm_name}")"
3633
NAME="$(cut -d '/' -f 2 <<< "${vm_name}")"
37-
VERSION="$( grep '"vm_version"' "${variables_file}" | cut -d '"' -f 4 )"
34+
VERSION="$(grep '"vm_version"' "${variables_file}" | cut -d '"' -f 4)"
3835
FILE="${1}"
3936
PROVIDER="$(printf '%s' "${FILE}" | rev | cut -d '.' -f 2 | rev)"
4037

4138
fi
4239
}
4340

44-
function release_uploaded_version(){
41+
function release_uploaded_version() {
4542

4643
# Release the version, and watch the party rage.
4744
${CURL} \
@@ -54,13 +51,13 @@ function release_uploaded_version(){
5451

5552
}
5653

57-
function upload_box(){
54+
function upload_box() {
5855

5956
# Perform the upload, and see the bits boil.
60-
if ! ${CURL} --tlsv1.2 --include --max-time 7200 --expect100-timeout 7200 --request PUT --output "$FILE.upload.log" --upload-file "$FILE" "$UPLOAD_PATH" ; then
57+
if ! ${CURL} --tlsv1.2 --include --max-time 7200 --expect100-timeout 7200 --request PUT --output "$FILE.upload.log" --upload-file "$FILE" "$UPLOAD_PATH"; then
6158
echo 'This probably "failed", but it mostly actually succeeded and did not get closed properly.'
6259
fi
63-
60+
6461
printf '\n-----------------------------------------------------\n'
6562
# tput setaf 5
6663
cat "$FILE.upload.log"
@@ -69,7 +66,7 @@ function upload_box(){
6966

7067
}
7168

72-
function vagrant_cloud_prep_upload(){
69+
function vagrant_cloud_prep_upload() {
7370

7471
# Prepare an upload path, and then extract that upload path from the JSON
7572
# response using the jq command.
@@ -80,15 +77,15 @@ function vagrant_cloud_prep_upload(){
8077

8178
}
8279

83-
function vagrant_cloud_deps(){
80+
function vagrant_cloud_deps() {
8481
## create the box
8582
box_creation_status=$(
86-
${CURL} \
87-
--silent \
88-
--header "Content-Type: application/json" \
89-
--header "Authorization: Bearer $VAGRANT_CLOUD_TOKEN" \
90-
"${base_url}es" \
91-
--data "
83+
${CURL} \
84+
--silent \
85+
--header "Content-Type: application/json" \
86+
--header "Authorization: Bearer $VAGRANT_CLOUD_TOKEN" \
87+
"${base_url}es" \
88+
--data "
9289
{
9390
\"box\": {
9491
\"username\": \"${ORG}\",
@@ -97,9 +94,10 @@ function vagrant_cloud_deps(){
9794
\"description\": \"${DESC}\",
9895
\"is_private\": \"false\"
9996
}
100-
}")
97+
}"
98+
)
10199

102-
if printf '%s' "${box_creation_status}" | grep 'tag' 1>/dev/null ; then
100+
if printf '%s' "${box_creation_status}" | grep 'tag' 1> /dev/null; then
103101
printf 'Congrats on creating the vagrant box %s!' "$(printf "%s" "${box_creation_status}" | jq -r '.tag')"
104102
else
105103
printf 'Box %s has already been created' "$(printf "%s" "${box_creation_status}" | jq -r '.tag')"
@@ -138,71 +136,77 @@ function vagrant_cloud_deps(){
138136

139137
}
140138

141-
function deps_check(){
139+
function deps_check() {
142140

143141
# The jq tool is needed to parse JSON responses.
144142
## adjusted to be more bash compliant
145-
if ! command -v jq 1>/dev/null ; then
146-
tput setaf 1; printf '\n\nThe jq utility is not installed.\n\n\n'; tput sgr0
143+
if ! command -v jq 1> /dev/null; then
144+
tput setaf 1
145+
printf '\n\nThe jq utility is not installed.\n\n\n'
146+
tput sgr0
147147
exit 1
148148
fi
149-
149+
150150
# Ensure the credentials file is available.
151151
if [ -f "$BASE/.credentialsrc" ]; then
152152
## added for shellcheck to ignore
153153
# shellcheck source=/dev/null
154154
. "$BASE/.credentialsrc"
155155
## if no credential file check if variables.json file
156-
elif [[ -f "${variables_file_path}" ]] ; then
156+
elif [[ -f "${variables_file_path}" ]]; then
157157
## check if vagrant_cloud_token exists
158-
if grep vagrant_cloud_token "${variables_file_path}" 1>/dev/null ; then
158+
if grep vagrant_cloud_token "${variables_file_path}" 1> /dev/null; then
159159
## pull token from there
160160
VAGRANT_CLOUD_TOKEN="$(grep vagrant_cloud_token ${variables_file_path} | cut -d '"' -f 4)"
161161
fi
162162
else
163-
tput setaf 1; printf '\nError. The credentials file is missing.\n\n'; tput sgr0
163+
tput setaf 1
164+
printf '\nError. The credentials file is missing.\n\n'
165+
tput sgr0
164166
exit 1
165167
fi
166-
168+
167169
if [ -z "${VAGRANT_CLOUD_TOKEN}" ]; then
168-
tput setaf 1; printf '\nError. The vagrant cloud token is missing. Add it to the credentials file.\n\n'; tput sgr0
170+
tput setaf 1
171+
printf '\nError. The vagrant cloud token is missing. Add it to the credentials file.\n\n'
172+
tput sgr0
169173
fi
170-
174+
171175
printf '\n\n'
172-
176+
173177
## validating the token
174178
status=$(${CURL} \
175179
--silent \
176180
--header "Authorization: Bearer ${VAGRANT_CLOUD_TOKEN}" \
177181
https://app.vagrantup.com/api/v1/authenticate)
178-
182+
179183
## checking if there was an error
180-
if printf '%s\n' "${status}" | grep error &>/dev/null ; then
184+
if printf '%s\n' "${status}" | grep error &> /dev/null; then
181185
## printing error message
182-
printf '%s\n' "${status}" | jq -r '.errors[].message'
186+
printf '%s\n' "${status}" | jq -r '.errors[].message'
183187
else
184188
## output that it is valid
185189
printf 'You have a valid token, congrats.\n'
186190
fi
187191

188192
}
189193

190-
function main(){
194+
function main() {
191195

192196
variables_file='variables.json'
193197
variables_file_path="${PWD}/${variables_file}"
194198

195-
if [[ $# -eq 5 ]] ; then
199+
if [[ $# -eq 5 ]]; then
196200
help
197-
elif [[ -n "${CIRCLECI:-}" ]] ; then
201+
elif [[ -n "${CIRCLECI:-}" ]]; then
198202
# this is an alternative logic path for specifically the CI
199203
# this will only take 1 arg ( the path to the box ) as an arg
200204
# for file upload
201205
ci_get_vars "${@}"
202206
else
203207
case $1 in
204-
-h|--help)
205-
help
208+
-h | --help)
209+
help
206210
;;
207211
esac
208212
fi
@@ -218,7 +222,6 @@ function main(){
218222

219223
CURL='curl'
220224

221-
222225
deps_check
223226
vagrant_cloud_deps
224227
vagrant_cloud_prep_upload
@@ -227,6 +230,6 @@ function main(){
227230
}
228231

229232
# https://blog.elreydetoda.site/cool-shell-tricks/#bashscriptingbashsmain
230-
if [[ "${0}" = "${BASH_SOURCE[0]}" ]] ; then
233+
if [[ "${0}" = "${BASH_SOURCE[0]}" ]]; then
231234
main "${@}"
232235
fi

0 commit comments

Comments
 (0)