forked from gravitational/teleport
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add agent support to Teleport AMIs for use with Terraform (gravitatio…
…nal#8387) * Initial commit adding agent mode * Disable auth_service and proxy_service for agents Also explicitly start the Teleport service when the config job has run * Remove kubernetes support from agent Preferred deployment method is in-cluster using the Helm chart * Handle difference between labels and static_labels * Don't override local hostname for agents
- Loading branch information
Showing
12 changed files
with
511 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
write_confd_file() { | ||
cat << EOF > ${TELEPORT_CONFD_DIR?}/conf | ||
TELEPORT_ROLE=agent | ||
EC2_REGION=us-west-2 | ||
TELEPORT_AGENT_APP_ENABLED=true | ||
TELEPORT_AGENT_APP_LABELS="env: prod|app: grafana" | ||
TELEPORT_AGENT_APP_NAME=grafana-prod | ||
TELEPORT_AGENT_APP_URI=grafana001.mycluster.hosting:3000 | ||
TELEPORT_JOIN_TOKEN=example-auth-token-for-tests | ||
TELEPORT_PROXY_SERVER_LB=gus-tftestkube4-proxy-bc9ba568645c3d80.elb.us-east-1.amazonaws.com | ||
EOF | ||
} | ||
|
||
load fixtures/common | ||
|
||
@test "[${TEST_SUITE?}] config file was generated without error" { | ||
[ ${GENERATE_EXIT_CODE?} -eq 0 ] | ||
} | ||
|
||
@test "[${TEST_SUITE?}] app_service.apps.description is blank" { | ||
load ${TELEPORT_CONFD_DIR?}/conf | ||
echo "${APP_APPS_BLOCK?}" | ||
echo "${APP_APPS_BLOCK?}" | grep -qE "^ description: \"\"" | ||
} |
25 changes: 25 additions & 0 deletions
25
assets/aws/files/tests/agent-app-insecure-skip-verify.bats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
write_confd_file() { | ||
cat << EOF > ${TELEPORT_CONFD_DIR?}/conf | ||
TELEPORT_ROLE=agent | ||
EC2_REGION=us-west-2 | ||
TELEPORT_AGENT_APP_ENABLED=true | ||
TELEPORT_AGENT_APP_LABELS="env: prod|app: grafana" | ||
TELEPORT_AGENT_APP_NAME=grafana-prod | ||
TELEPORT_AGENT_APP_URI=grafana001.mycluster.hosting:3000 | ||
TELEPORT_AGENT_APP_INSECURE_SKIP_VERIFY=true | ||
TELEPORT_JOIN_TOKEN=example-auth-token-for-tests | ||
TELEPORT_PROXY_SERVER_LB=gus-tftestkube4-proxy-bc9ba568645c3d80.elb.us-east-1.amazonaws.com | ||
EOF | ||
} | ||
|
||
load fixtures/common | ||
|
||
@test "[${TEST_SUITE?}] config file was generated without error" { | ||
[ ${GENERATE_EXIT_CODE?} -eq 0 ] | ||
} | ||
|
||
@test "[${TEST_SUITE?}] app_service.apps.insecure_skip_verify is set correctly" { | ||
load ${TELEPORT_CONFD_DIR?}/conf | ||
echo "${APP_APPS_BLOCK?}" | ||
echo "${APP_APPS_BLOCK?}" | grep -qE "^ insecure_skip_verify: true" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
write_confd_file() { | ||
cat << EOF > ${TELEPORT_CONFD_DIR?}/conf | ||
TELEPORT_ROLE=agent | ||
EC2_REGION=us-west-2 | ||
TELEPORT_AGENT_APP_ENABLED=true | ||
TELEPORT_AGENT_APP_LABELS="env: prod|app: grafana" | ||
TELEPORT_AGENT_APP_NAME=grafana-prod | ||
TELEPORT_AGENT_APP_PUBLIC_ADDR="grafana-prod.teleport.example.com" | ||
TELEPORT_AGENT_APP_URI=grafana001.mycluster.hosting:3000 | ||
TELEPORT_JOIN_TOKEN=example-auth-token-for-tests | ||
TELEPORT_PROXY_SERVER_LB=gus-tftestkube4-proxy-bc9ba568645c3d80.elb.us-east-1.amazonaws.com | ||
EOF | ||
} | ||
|
||
load fixtures/common | ||
|
||
@test "[${TEST_SUITE?}] config file was generated without error" { | ||
[ ${GENERATE_EXIT_CODE?} -eq 0 ] | ||
} | ||
|
||
@test "[${TEST_SUITE?}] app_service.apps.public_addr is set correctly" { | ||
load ${TELEPORT_CONFD_DIR?}/conf | ||
echo "${APP_APPS_BLOCK?}" | ||
echo "${APP_APPS_BLOCK?}" | grep -qE "^ public_addr: \"${TELEPORT_AGENT_APP_PUBLIC_ADDR}\"" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
write_confd_file() { | ||
cat << EOF > ${TELEPORT_CONFD_DIR?}/conf | ||
TELEPORT_ROLE=agent | ||
EC2_REGION=us-west-2 | ||
TELEPORT_AGENT_APP_DESCRIPTION="Production Grafana instance" | ||
TELEPORT_AGENT_APP_ENABLED=true | ||
TELEPORT_AGENT_APP_LABELS="env: prod|app: grafana" | ||
TELEPORT_AGENT_APP_NAME=grafana-prod | ||
TELEPORT_AGENT_APP_URI=grafana001.mycluster.hosting:3000 | ||
TELEPORT_JOIN_TOKEN=example-auth-token-for-tests | ||
TELEPORT_PROXY_SERVER_LB=gus-tftestkube4-proxy-bc9ba568645c3d80.elb.us-east-1.amazonaws.com | ||
EOF | ||
} | ||
|
||
load fixtures/common | ||
|
||
@test "[${TEST_SUITE?}] config file was generated without error" { | ||
[ ${GENERATE_EXIT_CODE?} -eq 0 ] | ||
} | ||
|
||
@test "[${TEST_SUITE?}] teleport.auth_servers is set correctly" { | ||
load ${TELEPORT_CONFD_DIR?}/conf | ||
cat "${TELEPORT_CONFIG_PATH?}" | ||
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_servers:" -A1 | grep -q "${TELEPORT_PROXY_SERVER_LB?}" | ||
} | ||
|
||
@test "[${TEST_SUITE?}] teleport.auth_token is set correctly" { | ||
load ${TELEPORT_CONFD_DIR?}/conf | ||
cat "${TELEPORT_CONFIG_PATH?}" | ||
cat "${TELEPORT_CONFIG_PATH?}" | grep -E "^ auth_token:" -A1 | grep -q "${TELEPORT_JOIN_TOKEN?}" | ||
} | ||
|
||
@test "[${TEST_SUITE?}] auth_service is not enabled" { | ||
load ${TELEPORT_CONFD_DIR?}/conf | ||
echo "${AUTH_BLOCK?}" | ||
echo "${AUTH_BLOCK?}" | grep -E "^ enabled: no" | ||
} | ||
|
||
@test "[${TEST_SUITE?}] proxy_service is not enabled" { | ||
load ${TELEPORT_CONFD_DIR?}/conf | ||
echo "${PROXY_BLOCK?}" | ||
echo "${PROXY_BLOCK?}" | grep -E "^ enabled: no" | ||
} | ||
|
||
# in each test, we echo the block so that if the test fails, the block is outputted | ||
@test "[${TEST_SUITE?}] app_service.enabled is set correctly" { | ||
load ${TELEPORT_CONFD_DIR?}/conf | ||
echo "${APP_BLOCK?}" | ||
echo "${APP_BLOCK?}" | grep -E "^ enabled: yes" | ||
} | ||
|
||
@test "[${TEST_SUITE?}] app_service.apps.name is set correctly" { | ||
load ${TELEPORT_CONFD_DIR?}/conf | ||
echo "${APP_APPS_BLOCK?}" | ||
echo "${APP_APPS_BLOCK?}" | grep -E "^ - name: ${TELEPORT_AGENT_APP_NAME}" | ||
} | ||
|
||
@test "[${TEST_SUITE?}] app_service.apps.description is set correctly" { | ||
load ${TELEPORT_CONFD_DIR?}/conf | ||
echo "${APP_APPS_BLOCK?}" | ||
echo "${APP_APPS_BLOCK?}" | grep -E "^ description: \"${TELEPORT_AGENT_APP_DESCRIPTION}\"" | ||
} | ||
|
||
@test "[${TEST_SUITE?}] app_service.apps.uri is set correctly" { | ||
load ${TELEPORT_CONFD_DIR?}/conf | ||
echo "${APP_APPS_BLOCK?}" | ||
echo "${APP_APPS_BLOCK?}" | grep -E "^ uri: \"${TELEPORT_AGENT_APP_URI}\"" | ||
} | ||
|
||
@test "[${TEST_SUITE?}] app_service.apps.public_addr is not set" { | ||
load ${TELEPORT_CONFD_DIR?}/conf | ||
echo "${APP_APPS_BLOCK?}" | ||
# this test inverts the regular behaviour of grep -q, so only succeeds if the line _isn't_ present | ||
echo "${APP_APPS_BLOCK?}" | { ! grep -qE "^ public_addr: "; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
write_confd_file() { | ||
cat << EOF > ${TELEPORT_CONFD_DIR?}/conf | ||
TELEPORT_ROLE=agent | ||
EC2_REGION=us-west-2 | ||
TELEPORT_JOIN_TOKEN=example-auth-token-for-tests | ||
TELEPORT_AGENT_DB_ENABLED=true | ||
TELEPORT_AGENT_DB_LABELS="env: prod|another: test|third: variable-env" | ||
TELEPORT_AGENT_DB_NAME=postgres-production | ||
TELEPORT_AGENT_DB_PROTOCOL=postgres | ||
TELEPORT_AGENT_DB_URI=postgres-prod123.rds.us-west-2.amazonaws.com:5432 | ||
TELEPORT_PROXY_SERVER_LB=gus-tftestkube4-proxy-bc9ba568645c3d80.elb.us-east-1.amazonaws.com | ||
EOF | ||
} | ||
|
||
load fixtures/common | ||
|
||
@test "[${TEST_SUITE?}] config file was generated without error" { | ||
[ ${GENERATE_EXIT_CODE?} -eq 0 ] | ||
} | ||
|
||
@test "[${TEST_SUITE?}] db_service.databases.description is blank" { | ||
load ${TELEPORT_CONFD_DIR?}/conf | ||
echo "${DB_DATABASES_BLOCK?}" | ||
echo "${DB_DATABASES_BLOCK?}" | grep -qE "^ description: \"\"" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
write_confd_file() { | ||
cat << EOF > ${TELEPORT_CONFD_DIR?}/conf | ||
TELEPORT_ROLE=agent | ||
EC2_REGION=us-west-2 | ||
TELEPORT_AGENT_DB_DESCRIPTION="Production PostgreSQL database" | ||
TELEPORT_AGENT_DB_ENABLED=true | ||
TELEPORT_AGENT_DB_LABELS="env: prod|another: test|third: variable-env" | ||
TELEPORT_AGENT_DB_NAME=postgres-production | ||
TELEPORT_AGENT_DB_PROTOCOL=postgres | ||
TELEPORT_AGENT_DB_URI=postgres-prod123.rds.us-west-2.amazonaws.com:5432 | ||
TELEPORT_JOIN_TOKEN=example-auth-token-for-tests | ||
TELEPORT_PROXY_SERVER_LB=gus-tftestkube4-proxy-bc9ba568645c3d80.elb.us-east-1.amazonaws.com | ||
EOF | ||
} | ||
|
||
load fixtures/common | ||
|
||
@test "[${TEST_SUITE?}] config file was generated without error" { | ||
[ ${GENERATE_EXIT_CODE?} -eq 0 ] | ||
} | ||
|
||
@test "[${TEST_SUITE?}] db_service.databases.aws.region is set correctly [default region]" { | ||
load ${TELEPORT_CONFD_DIR?}/conf | ||
echo "${DB_DATABASES_BLOCK?}" | ||
echo "${DB_DATABASES_BLOCK?}" | grep -E -A1 "^ aws:" | grep -E "^ region: ${EC2_REGION}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
write_confd_file() { | ||
cat << EOF > ${TELEPORT_CONFD_DIR?}/conf | ||
TELEPORT_ROLE=agent | ||
EC2_REGION=us-west-2 | ||
TELEPORT_AGENT_DB_DESCRIPTION="Production PostgreSQL database" | ||
TELEPORT_AGENT_DB_ENABLED=true | ||
TELEPORT_AGENT_DB_NAME=postgres-production | ||
TELEPORT_AGENT_DB_PROTOCOL=postgres | ||
TELEPORT_AGENT_DB_URI=postgres-prod123.rds.us-west-2.amazonaws.com:5432 | ||
TELEPORT_JOIN_TOKEN=example-auth-token-for-tests | ||
TELEPORT_PROXY_SERVER_LB=gus-tftestkube4-proxy-bc9ba568645c3d80.elb.us-east-1.amazonaws.com | ||
EOF | ||
} | ||
|
||
load fixtures/common | ||
|
||
@test "[${TEST_SUITE?}] config file was generated without error" { | ||
[ ${GENERATE_EXIT_CODE?} -eq 0 ] | ||
} | ||
|
||
@test "[${TEST_SUITE?}] db_service.databases.static_labels key does not exist when no labels are set" { | ||
load ${TELEPORT_CONFD_DIR?}/conf | ||
echo "${DB_DATABASES_BLOCK?}" | ||
# this test inverts the regular behaviour of grep -q, so only succeeds if the line _isn't_ present | ||
echo "${DB_DATABASES_BLOCK?}" | { ! grep -qE "^ static_labels: "; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
write_confd_file() { | ||
cat << EOF > ${TELEPORT_CONFD_DIR?}/conf | ||
TELEPORT_ROLE=agent | ||
EC2_REGION=us-west-2 | ||
TELEPORT_AGENT_DB_DESCRIPTION="Production PostgreSQL database" | ||
TELEPORT_AGENT_DB_ENABLED=true | ||
TELEPORT_AGENT_DB_LABELS="env: prod|another: test|third: variable-env" | ||
TELEPORT_AGENT_DB_NAME=postgres-production | ||
TELEPORT_AGENT_DB_PROTOCOL=postgres | ||
TELEPORT_AGENT_DB_REDSHIFT_CLUSTER_ID=redshift-cluster-id | ||
TELEPORT_AGENT_DB_URI=postgres-prod123.rds.us-west-2.amazonaws.com:5432 | ||
TELEPORT_JOIN_TOKEN=example-auth-token-for-tests | ||
TELEPORT_PROXY_SERVER_LB=gus-tftestkube4-proxy-bc9ba568645c3d80.elb.us-east-1.amazonaws.com | ||
EOF | ||
} | ||
|
||
load fixtures/common | ||
|
||
@test "[${TEST_SUITE?}] config file was generated without error" { | ||
[ ${GENERATE_EXIT_CODE?} -eq 0 ] | ||
} | ||
|
||
@test "[${TEST_SUITE?}] db_service.databases.aws.redshift.cluster_id is set correctly" { | ||
load ${TELEPORT_CONFD_DIR?}/conf | ||
echo "${DB_DATABASES_BLOCK?}" | ||
echo "${DB_DATABASES_BLOCK?}" | grep -E -A3 "^ aws:" | grep -E -A1 "^ redshift:" | grep -E "^ cluster_id: \"${TELEPORT_AGENT_DB_REDSHIFT_CLUSTER_ID}\"" | ||
} |
Oops, something went wrong.