From 7d1a5cf54e843aa4a66a47a1c4d6cd9044a0f2a1 Mon Sep 17 00:00:00 2001 From: dranderson <4012994+dranderson@users.noreply.github.com> Date: Tue, 29 Jan 2019 12:48:56 -0500 Subject: [PATCH 01/11] Initial Initial --- ansible/bakery.yml | 14 -------------- ansible/newrelic-infrastructure.yml | 21 ++++++++++++++++++++ bin/set-newrelic-license-key.sh | 30 +++++++++++++++++++++++++++++ codedeploy/appspec.yml | 4 ++++ terraform/cloud-config.yml | 1 + 5 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 ansible/newrelic-infrastructure.yml create mode 100755 bin/set-newrelic-license-key.sh diff --git a/ansible/bakery.yml b/ansible/bakery.yml index 606dcc1..3051c39 100644 --- a/ansible/bakery.yml +++ b/ansible/bakery.yml @@ -3,19 +3,6 @@ # Thanks https://www.tricksofthetrades.net/2017/10/02/ansible-local-playbooks/ for # the trick on installing locally using "hosts: 127.0.0.1" and "connection:local" -- name: Install New Relic Infrastructure - hosts: 127.0.0.1 - connection: local - become: yes - roles: - - newrelic.newrelic-infra - vars: - nrinfragent_os_name: CentOS - nrinfragent_os_version: 7 - nrinfragent_config: - license_key: ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ - log_file: /var/log/newrelic/nr-infra.log - log_to_stdout: false - name: Install Web Application hosts: 127.0.0.1 @@ -26,7 +13,6 @@ - prepare-web-content - prepare-codedeploy - - name: Harden Server hosts: 127.0.0.1 connection: local diff --git a/ansible/newrelic-infrastructure.yml b/ansible/newrelic-infrastructure.yml new file mode 100644 index 0000000..f489fa6 --- /dev/null +++ b/ansible/newrelic-infrastructure.yml @@ -0,0 +1,21 @@ +--- +# Use ansible to install the newrelic infra agent. + +# Thanks https://www.tricksofthetrades.net/2017/10/02/ansible-local-playbooks/ for +# the trick on installing locally using "hosts: 127.0.0.1" and "connection:local" +- name: Install New Relic Infrastructure + hosts: 127.0.0.1 + connection: local + become: yes + roles: + - newrelic.newrelic-infra + vars: + nrinfragent_os_name: CentOS + nrinfragent_os_version: 7 + nrinfragent_config: + license_key: ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ + log_file: /var/log/newrelic/nr-infra.log + log_to_stdout: false + +-name: Set the newrelic license key + local_action: bash /app/bin/set-newrelic-license-key.sh \ No newline at end of file diff --git a/bin/set-newrelic-license-key.sh b/bin/set-newrelic-license-key.sh new file mode 100755 index 0000000..6d60f5b --- /dev/null +++ b/bin/set-newrelic-license-key.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Set the newrelic license key fron AWS credentials +# +# Set bash unofficial strict mode http://redsymbol.net/articles/unofficial-bash-strict-mode/ +set -euo pipefail + +# Set DEBUG to true for enhanced debugging: run prefixed with "DEBUG=true" +${DEBUG:-false} && set -vx +# Credit to https://stackoverflow.com/a/17805088 +# and http://wiki.bash-hackers.org/scripting/debuggingtips +export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' + +# Credit to http://stackoverflow.com/a/246128/424301 +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +BASE_DIR="$DIR/.." +export BASE_DIR + +NEWRELIC_CONFIG_FILE="/etc/newrelic-infra.yml" +# Thanks Stack Overflow https://stackoverflow.com/a/9735663/424301 +EC2_AVAIL_ZONE=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone) +EC2_REGION="$(sed 's/[a-z]$//' <<<"$EC2_AVAIL_ZONE")" + +NEWRELIC_LICENSE_KEY=$(aws secretsmanager get-secret-value \ + --region="$EC2_REGION" \ + --secret-id newrelic_license \ + --output text \ + --query '[SecretString]') + +cp -a "${NEWRELIC_CONFIG_FILE}" "${NEWRELIC_CONFIG_FILE}.orig" +sed "s/ZZZZ*ZZZZ/${NEWRELIC_LICENSE_KEY}/" "${NEWRELIC_CONFIG_FILE}.orig" > "${NEWRELIC_CONFIG_FILE}" diff --git a/codedeploy/appspec.yml b/codedeploy/appspec.yml index e0f94aa..2538144 100644 --- a/codedeploy/appspec.yml +++ b/codedeploy/appspec.yml @@ -6,6 +6,10 @@ files: destination: /app/application - source: src destination: /app/src + - source: bin + destination: /app/bin + - source: ansible + destination: /app/ansible hooks: ApplicationStop: - location: bin/ApplicationStop.sh diff --git a/terraform/cloud-config.yml b/terraform/cloud-config.yml index 3872c61..ecf0cea 100644 --- a/terraform/cloud-config.yml +++ b/terraform/cloud-config.yml @@ -1,3 +1,4 @@ #cloud-config runcmd: - sudo -u centos ansible-playbook -l localhost /app/ansible/codedeploy.yml + - sudo -u centos ansible-playbook -l localhost /app/ansible/newrelic-infrastructure.yml From 95364b0a8ba2debd601ee5e84be469c2b63c7f97 Mon Sep 17 00:00:00 2001 From: dranderson <4012994+dranderson@users.noreply.github.com> Date: Tue, 29 Jan 2019 16:04:09 -0500 Subject: [PATCH 02/11] Fix newrelic install Fix newrelic install --- ansible/newrelic-infrastructure.yml | 9 +++++++-- terraform/cloud-config.yml | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ansible/newrelic-infrastructure.yml b/ansible/newrelic-infrastructure.yml index f489fa6..2c80d36 100644 --- a/ansible/newrelic-infrastructure.yml +++ b/ansible/newrelic-infrastructure.yml @@ -17,5 +17,10 @@ log_file: /var/log/newrelic/nr-infra.log log_to_stdout: false --name: Set the newrelic license key - local_action: bash /app/bin/set-newrelic-license-key.sh \ No newline at end of file +- name: Set the newrelic license key + hosts: 127.0.0.1 + connection: local + become: yes + tasks: + - command: ansible-galaxy install newrelic.newrelic-infra + - command: bash /app/bin/set-newrelic-license-key.sh \ No newline at end of file diff --git a/terraform/cloud-config.yml b/terraform/cloud-config.yml index ecf0cea..ec641ea 100644 --- a/terraform/cloud-config.yml +++ b/terraform/cloud-config.yml @@ -1,4 +1,4 @@ #cloud-config runcmd: - sudo -u centos ansible-playbook -l localhost /app/ansible/codedeploy.yml - - sudo -u centos ansible-playbook -l localhost /app/ansible/newrelic-infrastructure.yml + - ansible-playbook -l localhost /app/ansible/newrelic-infrastructure.yml From 7436b3bc05a4b1bca3fe5aa8e6be92071c40da02 Mon Sep 17 00:00:00 2001 From: dranderson <4012994+dranderson@users.noreply.github.com> Date: Tue, 29 Jan 2019 16:14:56 -0500 Subject: [PATCH 03/11] Install newrelic.newrelic-infra newrelic.newrelic-infra first --- ansible/newrelic-infrastructure.yml | 11 +++++++++-- terraform/cloud-config.yml | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ansible/newrelic-infrastructure.yml b/ansible/newrelic-infrastructure.yml index 2c80d36..544605b 100644 --- a/ansible/newrelic-infrastructure.yml +++ b/ansible/newrelic-infrastructure.yml @@ -3,6 +3,13 @@ # Thanks https://www.tricksofthetrades.net/2017/10/02/ansible-local-playbooks/ for # the trick on installing locally using "hosts: 127.0.0.1" and "connection:local" +- name: Install newrelic.newrelic-infra + hosts: 127.0.0.1 + connection: local + become: yes + tasks: + - command: ansible-galaxy install newrelic.newrelic-infra + - name: Install New Relic Infrastructure hosts: 127.0.0.1 connection: local @@ -22,5 +29,5 @@ connection: local become: yes tasks: - - command: ansible-galaxy install newrelic.newrelic-infra - - command: bash /app/bin/set-newrelic-license-key.sh \ No newline at end of file + - command: bash /app/bin/set-newrelic-license-key.sh + \ No newline at end of file diff --git a/terraform/cloud-config.yml b/terraform/cloud-config.yml index ec641ea..ecf0cea 100644 --- a/terraform/cloud-config.yml +++ b/terraform/cloud-config.yml @@ -1,4 +1,4 @@ #cloud-config runcmd: - sudo -u centos ansible-playbook -l localhost /app/ansible/codedeploy.yml - - ansible-playbook -l localhost /app/ansible/newrelic-infrastructure.yml + - sudo -u centos ansible-playbook -l localhost /app/ansible/newrelic-infrastructure.yml From 67bfa325dbdd62fdc3182445d63bef63c57c8ac5 Mon Sep 17 00:00:00 2001 From: dranderson <4012994+dranderson@users.noreply.github.com> Date: Tue, 29 Jan 2019 20:50:38 -0500 Subject: [PATCH 04/11] move newrelic install move newrelic install back to bakery --- ansible/bakery.yml | 14 ++++++++++++++ ansible/newrelic-infrastructure.yml | 20 -------------------- terraform/cloud-config.yml | 2 +- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/ansible/bakery.yml b/ansible/bakery.yml index 3051c39..606dcc1 100644 --- a/ansible/bakery.yml +++ b/ansible/bakery.yml @@ -3,6 +3,19 @@ # Thanks https://www.tricksofthetrades.net/2017/10/02/ansible-local-playbooks/ for # the trick on installing locally using "hosts: 127.0.0.1" and "connection:local" +- name: Install New Relic Infrastructure + hosts: 127.0.0.1 + connection: local + become: yes + roles: + - newrelic.newrelic-infra + vars: + nrinfragent_os_name: CentOS + nrinfragent_os_version: 7 + nrinfragent_config: + license_key: ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ + log_file: /var/log/newrelic/nr-infra.log + log_to_stdout: false - name: Install Web Application hosts: 127.0.0.1 @@ -13,6 +26,7 @@ - prepare-web-content - prepare-codedeploy + - name: Harden Server hosts: 127.0.0.1 connection: local diff --git a/ansible/newrelic-infrastructure.yml b/ansible/newrelic-infrastructure.yml index 544605b..5ea7139 100644 --- a/ansible/newrelic-infrastructure.yml +++ b/ansible/newrelic-infrastructure.yml @@ -3,26 +3,6 @@ # Thanks https://www.tricksofthetrades.net/2017/10/02/ansible-local-playbooks/ for # the trick on installing locally using "hosts: 127.0.0.1" and "connection:local" -- name: Install newrelic.newrelic-infra - hosts: 127.0.0.1 - connection: local - become: yes - tasks: - - command: ansible-galaxy install newrelic.newrelic-infra - -- name: Install New Relic Infrastructure - hosts: 127.0.0.1 - connection: local - become: yes - roles: - - newrelic.newrelic-infra - vars: - nrinfragent_os_name: CentOS - nrinfragent_os_version: 7 - nrinfragent_config: - license_key: ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ - log_file: /var/log/newrelic/nr-infra.log - log_to_stdout: false - name: Set the newrelic license key hosts: 127.0.0.1 diff --git a/terraform/cloud-config.yml b/terraform/cloud-config.yml index ecf0cea..ec641ea 100644 --- a/terraform/cloud-config.yml +++ b/terraform/cloud-config.yml @@ -1,4 +1,4 @@ #cloud-config runcmd: - sudo -u centos ansible-playbook -l localhost /app/ansible/codedeploy.yml - - sudo -u centos ansible-playbook -l localhost /app/ansible/newrelic-infrastructure.yml + - ansible-playbook -l localhost /app/ansible/newrelic-infrastructure.yml From dce63c7d47f9a7cd18aaeb3bc2e8859d18bb03ea Mon Sep 17 00:00:00 2001 From: dranderson <4012994+dranderson@users.noreply.github.com> Date: Tue, 29 Jan 2019 20:59:42 -0500 Subject: [PATCH 05/11] restart newrelic after key restart newrelic after key --- ansible/newrelic-infrastructure.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ansible/newrelic-infrastructure.yml b/ansible/newrelic-infrastructure.yml index 5ea7139..b0ec75d 100644 --- a/ansible/newrelic-infrastructure.yml +++ b/ansible/newrelic-infrastructure.yml @@ -10,4 +10,11 @@ become: yes tasks: - command: bash /app/bin/set-newrelic-license-key.sh + +- name: Restart newrelic + hosts: 127.0.0.1 + connection: local + become: yes + tasks: + - command: service newrelic-infra restart \ No newline at end of file From 6740dfd93b6d9c15769a7ef180a626ae037b95e1 Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Tue, 29 Jan 2019 21:00:47 -0500 Subject: [PATCH 06/11] Move CodeDeploy build around to fix before / after When CodeDeploy was running, it was leaving a different set of files in /app than Ansible & Packer originally left there. There were also duplicate virtualenv files in /app/venv and /app/build/venv. This fixes that too. --- Jenkinsfile | 2 +- .../bin/build.sh => bin/build-codedeploy.sh | 26 +++++++++---------- .../bin => bin/codedeploy}/AfterInstall.sh | 0 .../codedeploy}/ApplicationStart.sh | 0 .../bin => bin/codedeploy}/ApplicationStop.sh | 0 .../bin => bin/codedeploy}/BeforeInstall.sh | 0 .../bin => bin/codedeploy}/ValidateService.sh | 0 codedeploy/appspec.yml | 10 +++---- 8 files changed, 19 insertions(+), 19 deletions(-) rename codedeploy/bin/build.sh => bin/build-codedeploy.sh (78%) rename {codedeploy/bin => bin/codedeploy}/AfterInstall.sh (100%) rename {codedeploy/bin => bin/codedeploy}/ApplicationStart.sh (100%) rename {codedeploy/bin => bin/codedeploy}/ApplicationStop.sh (100%) rename {codedeploy/bin => bin/codedeploy}/BeforeInstall.sh (100%) rename {codedeploy/bin => bin/codedeploy}/ValidateService.sh (100%) diff --git a/Jenkinsfile b/Jenkinsfile index 32495ca..e8bf12d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -182,7 +182,7 @@ stage('Build CodeDeploy Archive') { node { unstash 'src' wrap.call({ - sh ("./codedeploy/bin/build.sh") + sh ("./bin/build-codedeploy.sh") }) } } diff --git a/codedeploy/bin/build.sh b/bin/build-codedeploy.sh similarity index 78% rename from codedeploy/bin/build.sh rename to bin/build-codedeploy.sh index e61b0de..126fe6c 100755 --- a/codedeploy/bin/build.sh +++ b/bin/build-codedeploy.sh @@ -13,11 +13,9 @@ export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" BASE_DIR="$DIR/.." BUILD_DIR="$BASE_DIR/build" -ANSIBLE_DIR="$BASE_DIR/../ansible" -APPLICTION_DIR="$BASE_DIR/../application" -SRC_DIR="$BASE_DIR/../src" -VENV_DIR="$BASE_DIR/../venv" -DOCKER_DIR="$BASE_DIR/.." +ANSIBLE_DIR="$BASE_DIR/ansible" +APPLICTION_DIR="$BASE_DIR/application" +SRC_DIR="$BASE_DIR/src" GIT_REV="$(git rev-parse --short HEAD)" BUILD_NUMBER=${BUILD_NUMBER:-0} @@ -39,20 +37,22 @@ fi mkdir -p "$BUILD_DIR/socket" echo Build docker container $CONTAINERNAME -docker build -f=Dockerfile -t "$CONTAINERNAME" "$DOCKER_DIR" +docker build -f=Dockerfile -t "$CONTAINERNAME" "$BASE_DIR" echo Create python virtual environment -docker run --rm -v "$DOCKER_DIR:/src" "$CONTAINERNAME" /bin/bash -c \ - "mkdir -p /src/venv ; \ - cp -fa /app/venv/* /src/venv" +docker run \ + --rm \ + -v "$BASE_DIR:/src" \ + "$CONTAINERNAME" \ + /bin/bash -c \ + "mkdir -p /src/build/venv ; \ + cp -fa /app/venv/* /src/build/venv" SOURCES="$BASE_DIR/bin $ANSIBLE_DIR $APPLICTION_DIR $SRC_DIR -$BASE_DIR/appspec.yml -$BASE_DIR/bin -$VENV_DIR" +$BASE_DIR/codedeploy/appspec.yml" for src in $SOURCES; do cp -a "$src" "$BUILD_DIR" done @@ -70,7 +70,7 @@ done ) echo Remove docker generated files -docker run --rm -v "$DOCKER_DIR:/src" "$CONTAINERNAME" /bin/bash -c \ +docker run --rm -v "$BASE_DIR:/src" "$CONTAINERNAME" /bin/bash -c \ "rm -rf /src/venv" cd "$BUILD_DIR" diff --git a/codedeploy/bin/AfterInstall.sh b/bin/codedeploy/AfterInstall.sh similarity index 100% rename from codedeploy/bin/AfterInstall.sh rename to bin/codedeploy/AfterInstall.sh diff --git a/codedeploy/bin/ApplicationStart.sh b/bin/codedeploy/ApplicationStart.sh similarity index 100% rename from codedeploy/bin/ApplicationStart.sh rename to bin/codedeploy/ApplicationStart.sh diff --git a/codedeploy/bin/ApplicationStop.sh b/bin/codedeploy/ApplicationStop.sh similarity index 100% rename from codedeploy/bin/ApplicationStop.sh rename to bin/codedeploy/ApplicationStop.sh diff --git a/codedeploy/bin/BeforeInstall.sh b/bin/codedeploy/BeforeInstall.sh similarity index 100% rename from codedeploy/bin/BeforeInstall.sh rename to bin/codedeploy/BeforeInstall.sh diff --git a/codedeploy/bin/ValidateService.sh b/bin/codedeploy/ValidateService.sh similarity index 100% rename from codedeploy/bin/ValidateService.sh rename to bin/codedeploy/ValidateService.sh diff --git a/codedeploy/appspec.yml b/codedeploy/appspec.yml index 2538144..6c7275f 100644 --- a/codedeploy/appspec.yml +++ b/codedeploy/appspec.yml @@ -12,17 +12,17 @@ files: destination: /app/ansible hooks: ApplicationStop: - - location: bin/ApplicationStop.sh + - location: bin/codedeploy/ApplicationStop.sh timeout: 600 BeforeInstall: - - location: bin/BeforeInstall.sh + - location: bin/codedeploy/BeforeInstall.sh timeout: 30 AfterInstall: - - location: bin/AfterInstall.sh + - location: bin/codedeploy/AfterInstall.sh timeout: 300 ApplicationStart: - - location: bin/ApplicationStart.sh + - location: bin/codedeploy/ApplicationStart.sh timeout: 120 ValidateService: - - location: bin/ValidateService.sh + - location: bin/codedeploy/ValidateService.sh timeout: 60 From a118bb87cde258024493555d66277c219f7cffbf Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Tue, 29 Jan 2019 21:11:49 -0500 Subject: [PATCH 07/11] Clean root owned docker files before every step --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index e8bf12d..08c45f0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -33,6 +33,8 @@ def wrap = { fn-> variable: 'NEWRELIC_LICENSE_KEY_OVERRIDE')]) { sh (""" cp env.sh.sample env.sh + . bin/common.sh + clean_root_owned_docker_files rm -rf build mkdir build """) From 1d187c8c75efc6b3e8677199876bbd5ba0c2c192 Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Tue, 29 Jan 2019 21:18:25 -0500 Subject: [PATCH 08/11] Move clean workspace scriptlet to full script --- Jenkinsfile | 8 +------- bin/clean-workspace.sh | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) create mode 100755 bin/clean-workspace.sh diff --git a/Jenkinsfile b/Jenkinsfile index 08c45f0..a846962 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -31,13 +31,7 @@ def wrap = { fn-> variable: 'GOOGLE_APPLICATION_CREDENTIALS_OVERRIDE')]) { withCredentials([string(credentialsId: 'newrelic.license.key', variable: 'NEWRELIC_LICENSE_KEY_OVERRIDE')]) { - sh (""" - cp env.sh.sample env.sh - . bin/common.sh - clean_root_owned_docker_files - rm -rf build - mkdir build - """) + sh ("bin/clean-workspace.sh") fn() } } diff --git a/bin/clean-workspace.sh b/bin/clean-workspace.sh new file mode 100755 index 0000000..a227196 --- /dev/null +++ b/bin/clean-workspace.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# clean workspace +# +# Set bash unofficial strict mode http://redsymbol.net/articles/unofficial-bash-strict-mode/ +set -euo pipefail + +# Set DEBUG to true for enhanced debugging: run prefixed with "DEBUG=true" +${DEBUG:-false} && set -vx +# Credit to https://stackoverflow.com/a/17805088 +# and http://wiki.bash-hackers.org/scripting/debuggingtips +export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' + +# Credit to http://stackoverflow.com/a/246128/424301 +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +BASE_DIR="$DIR/.." +BUILD_DIR="$BASE_DIR/build" +export BASE_DIR + +# shellcheck disable=SC1090 +. "$DIR/common.sh" + +cp "$BASE_DIR/env.sh.sample" "$BASE_DIR/env.sh" +clean_root_owned_docker_files +rm -rf "$BUILD_DIR" +mkdir "$BUILD_DIR" From fc63fa7175d45ea866c7aa42f4b037c16479c033 Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Tue, 29 Jan 2019 21:22:05 -0500 Subject: [PATCH 09/11] Fix up CodeDeploy BASE_DIR --- bin/codedeploy/AfterInstall.sh | 2 +- bin/codedeploy/ApplicationStart.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/codedeploy/AfterInstall.sh b/bin/codedeploy/AfterInstall.sh index 93d1db5..2fcbca4 100755 --- a/bin/codedeploy/AfterInstall.sh +++ b/bin/codedeploy/AfterInstall.sh @@ -16,7 +16,7 @@ export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' # Credit to http://stackoverflow.com/a/246128/424301 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -BASE_DIR="$DIR/.." +BASE_DIR="$DIR/../.." ANSIBLE_DIR="$BASE_DIR/ansible" # Invoke Ansible for final set up diff --git a/bin/codedeploy/ApplicationStart.sh b/bin/codedeploy/ApplicationStart.sh index 5d08139..c2698ca 100755 --- a/bin/codedeploy/ApplicationStart.sh +++ b/bin/codedeploy/ApplicationStart.sh @@ -16,7 +16,7 @@ export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' # Credit to http://stackoverflow.com/a/246128/424301 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -BASE_DIR="$DIR/.." +BASE_DIR="$DIR/../.." ANSIBLE_DIR="$BASE_DIR/ansible" # Invoke Ansible for final set up From 63c330e5145fa472a5c8bf9a435630c48d793cc0 Mon Sep 17 00:00:00 2001 From: dranderson <4012994+dranderson@users.noreply.github.com> Date: Tue, 29 Jan 2019 22:15:48 -0500 Subject: [PATCH 10/11] fix newrelic log location fix newrelic log location --- ansible/bakery.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/bakery.yml b/ansible/bakery.yml index 606dcc1..59827fe 100644 --- a/ansible/bakery.yml +++ b/ansible/bakery.yml @@ -14,7 +14,7 @@ nrinfragent_os_version: 7 nrinfragent_config: license_key: ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ - log_file: /var/log/newrelic/nr-infra.log + log_file: /var/log/newrelic-infra/nr-infra.log log_to_stdout: false - name: Install Web Application From 3230f3459a18e0a1bb64c9e92ed620684f5341a6 Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Tue, 29 Jan 2019 23:28:12 -0500 Subject: [PATCH 11/11] Simplify by running more than one playbook --- terraform/cloud-config.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/terraform/cloud-config.yml b/terraform/cloud-config.yml index ec641ea..9e449bb 100644 --- a/terraform/cloud-config.yml +++ b/terraform/cloud-config.yml @@ -1,4 +1,3 @@ #cloud-config runcmd: - - sudo -u centos ansible-playbook -l localhost /app/ansible/codedeploy.yml - - ansible-playbook -l localhost /app/ansible/newrelic-infrastructure.yml + - ansible-playbook -l localhost /app/ansible/codedeploy.yml /app/ansible/newrelic-infrastructure.yml