[infra-proxy-service] Auto populate terraform deployed chef servers.
@@ -124,6 +124,32 @@ configure_retention() {
}'
}
+configure_automate_infra_views() {
+ if chef-automate dev grpcurl automate-gateway list | grep "chef.automate.api.infra_proxy.InfraProxy" &> /dev/null; then
+ chef_server_admin_key=$(cat "/hab/chef-server-admin-key.txt")
+ server_id="auto-deployed-chef-server"
+ org_id="auto-deployed-chef-org"
+ if ! chef-automate dev grpcurl automate-gateway -- chef.automate.api.infra_proxy.InfraProxy.GetServer -d '{"id": "${server_id}"}' | grep "${server_id}" &> /dev/null; then
+ chef-automate dev grpcurl automate-gateway -- chef.automate.api.infra_proxy.InfraProxy.CreateServer -d '{
+ "id": "${server_id}",
+ "name": "${server_id}",
+ "fqdn": "localhost",
+ "ip_address": "127.0.0.1",
+ }'
+ fi
+
+ if ! chef-automate dev grpcurl automate-gateway -- chef.automate.api.infra_proxy.InfraProxy.GetOrg -d '{"id": "${org_id}", "server_id": "${server_id}"}' | grep "${org_id}" &> /dev/null; then
+ chef-automate dev grpcurl automate-gateway -- chef.automate.api.infra_proxy.InfraProxy.CreateOrg -d '{
+ "id": "${org_id}",
+ "name": "${chef_server_org}",
+ "admin_user": "${chef_server_admin_name}",
+ "admin_key": "${chef_server_admin_key}",
+ "server_id": "${server_id}",
+ }'
+ fi
+ fi
+}
+
if [[ "${airgapped}" == "false" ]]; then
if ! command -v unzip &> /dev/null; then
command -v apt-get &> /dev/null && apt-get install -y unzip
@@ -227,6 +253,9 @@ EOH
berks install -b /tmp/.Berksfile -c /tmp/.berks.config.json
berks upload -b /tmp/.Berksfile -c /tmp/.berks.config.json
+ # add record to automate infra views to pre-populate deployed chef server.
+ configure_automate_infra_views
+
if [[ "${enable_workflow}" == "true" ]]; then
if ! chef-server-ctl user-list | grep delivery &> /dev/null; then
chef-server-ctl user-create delivery delivery delivery delivery@delivery.com '$3CUR3' -d -f /etc/chef-automate/chef-server-delivery-key.txt
