Run the scenario using the following command
shikari create -n repro -s 1 -i <image_path> -t https://gist.githubusercontent.com/Ranjandas/c24fbde0b922d548e74a7be5da5c8046/raw/798c845bb646a54ce0b3d902c7d491c144119de6/hashibox.yaml
| # disable port-mapping, mounts, containerd etc | |
| plain: true | |
| provision: | |
| - mode: system # install Consul and Nomad Licenses if any | |
| script: | | |
| #!/bin/bash | |
| if [[ -n $CONSUL_LICENSE ]]; then | |
| echo "CONSUL_LICENSE=$CONSUL_LICENSE" > /etc/consul.d/consul.env | |
| fi | |
| if [[ -n $NOMAD_LICENSE ]]; then | |
| echo "NOMAD_LICENSE=$NOMAD_LICENSE" > /etc/nomad.d/nomad.env | |
| fi | |
| - mode: system # Configure Consul common settings | |
| script: | | |
| #!/bin/bash | |
| # common config for Server and Client | |
| cat <<-EOF > /etc/consul.d/consul.hcl | |
| data_dir = "/opt/consul/data" | |
| log_level = "INFO" | |
| bind_addr = {{ "\"{{ GetInterfaceIP \\\"lima0\\\"}}\"" }} | |
| client_addr = "0.0.0.0" | |
| retry_join = ["lima-${SHIKARI_CLUSTER_NAME}-srv-01.local"] | |
| datacenter = "${SHIKARI_CLUSTER_NAME}" | |
| ui_config { | |
| enabled = true | |
| } | |
| EOF | |
| - mode: system # Configure Consul server settings | |
| script: | | |
| #!/bin/bash | |
| if [[ ${SHIKARI_VM_MODE} == "server" ]]; then | |
| cat <<-EOF > /etc/consul.d/server.hcl | |
| connect { | |
| enabled = true | |
| } | |
| server = true | |
| bootstrap_expect = $SHIKARI_SERVER_COUNT | |
| EOF | |
| fi | |
| - mode: system # Configure Consul client settings | |
| script: | | |
| #!/bin/bash | |
| if [[ ${SHIKARI_VM_MODE} == "client" ]] || [[ ${SHIKARI_CLIENT_COUNT} -lt 1 ]]; then | |
| cat <<-EOF > /etc/consul.d/client.hcl | |
| recursors = ["1.1.1.1", "8.8.8.8"] | |
| ports { | |
| grpc = 8502 | |
| } | |
| EOF | |
| fi | |
| - mode: system # Configure Nomad common settings | |
| script: | | |
| #!/bin/bash | |
| # allow the DC name to be overriden by NOMAD_DC environment variable | |
| NOMAD_DC_NAME="${NOMAD_DC:-$SHIKARI_CLUSTER_NAME}" | |
| cat <<-EOF > /etc/nomad.d/nomad.hcl | |
| data_dir = "/opt/nomad/data" | |
| bind_addr = "0.0.0.0" | |
| datacenter = "${NOMAD_DC_NAME}" | |
| log_level = "DEBUG" | |
| advertise { | |
| http = {{ "\"{{ GetInterfaceIP \\\"lima0\\\"}}\"" }} | |
| rpc = {{ "\"{{ GetInterfaceIP \\\"lima0\\\"}}\"" }} | |
| serf = {{ "\"{{ GetInterfaceIP \\\"lima0\\\"}}\"" }} | |
| } | |
| EOF | |
| - mode: system # configure Nomad server settings | |
| script: | | |
| #!/bin/bash | |
| if [[ ${SHIKARI_VM_MODE} == "server" ]]; then | |
| cat <<-EOF > /etc/nomad.d/server.hcl | |
| server { | |
| #license_path = "/etc/nomad.d/license.hclic" | |
| enabled = true | |
| bootstrap_expect = $SHIKARI_SERVER_COUNT | |
| server_join { | |
| retry_join = ["lima-${SHIKARI_CLUSTER_NAME}-srv-01.local"] | |
| } | |
| } | |
| EOF | |
| fi | |
| - mode: system # configure Nomad client settings | |
| script: | | |
| #!/bin/bash | |
| NOMAD_NODE_POOL=${NOMAD_NODE_POOL:-default} | |
| if [[ ${SHIKARI_VM_MODE} == "client" ]] || [[ ${SHIKARI_CLIENT_COUNT} -lt 1 ]]; then | |
| cat <<-EOF > /etc/nomad.d/client.hcl | |
| client { | |
| enabled = true | |
| servers = ["lima-${SHIKARI_CLUSTER_NAME}-srv-01.local"] | |
| network_interface = "lima0" | |
| node_pool = "${NOMAD_NODE_POOL}" | |
| } | |
| consul { | |
| address = {{ "\"{{ GetInterfaceIP \\\"lima0\\\"}}:8500\"" }} | |
| grpc_address = {{ "\"{{ GetInterfaceIP \\\"lima0\\\"}}:8502\"" }} | |
| } | |
| EOF | |
| fi | |
| - mode: system | |
| script: | | |
| systemctl enable --now docker | |
| systemctl enable --now nomad consul | |
| networks: | |
| - lima: shared | |
| vmType: qemu | |
| env: | |
| SHIKARI_SCENARIO_NAME: "NET-10758-nomad-consul-quickstart" |