From 8106ec54045c2afd18900351c5ebca7c546b1c6b Mon Sep 17 00:00:00 2001 From: Andrew Nowak Date: Tue, 9 Jul 2024 11:18:16 +0100 Subject: [PATCH 1/2] Add option to not automatically start fluentbit Currently if you want or need to add extra fluentbit config at instance start time (ie. in user data script) you must `systemctl restart td-agent-bit.service`, which means that the cloud-init logs up to that point will be resent from the start, meaning some logs are sent twice! If instead we never add the start-fluentbit script, we can start it when we have the full config in place, and still benefit from `devx-logs`! --- roles/cdk-base/README.md | 10 ++++++++++ roles/cdk-base/defaults/main.yml | 3 ++- roles/cdk-base/tasks/main.yml | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/roles/cdk-base/README.md b/roles/cdk-base/README.md index 954c08a1..204f134d 100644 --- a/roles/cdk-base/README.md +++ b/roles/cdk-base/README.md @@ -106,3 +106,13 @@ Resources: _While not required, it is strongly recommended to [enable tag metadata on your instance](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-launchtemplatedata-metadataoptions.html#cfn-ec2-launchtemplate-launchtemplatedata-metadataoptions-instancemetadatatags) as this allows tag lookup without requiring remote AWS API calls at runtime._ + +## Options + +- `start_fluentbit`: boolean, default `true` + + Set this to `false` if you do not want log shipping to start automatically. + This is useful if you will add or change the log shipping config supplied by + `devx-logs`. If you have set this to `false` you are now responsible for + starting `td-agent-bit.service` in your user data script, and if you fail to do + so logs will not be shipped. diff --git a/roles/cdk-base/defaults/main.yml b/roles/cdk-base/defaults/main.yml index c21c7377..6ae9cbd5 100644 --- a/roles/cdk-base/defaults/main.yml +++ b/roles/cdk-base/defaults/main.yml @@ -1,2 +1,3 @@ --- -dist_bucket: amigo-data \ No newline at end of file +dist_bucket: amigo-data +start_fluentbit: true diff --git a/roles/cdk-base/tasks/main.yml b/roles/cdk-base/tasks/main.yml index d821b4b5..a8fee467 100644 --- a/roles/cdk-base/tasks/main.yml +++ b/roles/cdk-base/tasks/main.yml @@ -35,6 +35,7 @@ chmod +x /var/lib/cloud/scripts/per-instance/02-$NAME when: - ansible_os_family == "Debian" + - start_fluentbit - name: Remove syslog output shell: | From 862c22bb127eac6ace46ac75bbb28ad11c59aabc Mon Sep 17 00:00:00 2001 From: Andrew Nowak <10963046+andrew-nowak@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:14:31 +0100 Subject: [PATCH 2/2] Update README.md explaining how to start fluentbit --- roles/cdk-base/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/roles/cdk-base/README.md b/roles/cdk-base/README.md index 204f134d..7e9b2860 100644 --- a/roles/cdk-base/README.md +++ b/roles/cdk-base/README.md @@ -114,5 +114,6 @@ as this allows tag lookup without requiring remote AWS API calls at runtime._ Set this to `false` if you do not want log shipping to start automatically. This is useful if you will add or change the log shipping config supplied by `devx-logs`. If you have set this to `false` you are now responsible for - starting `td-agent-bit.service` in your user data script, and if you fail to do - so logs will not be shipped. + starting `td-agent-bit.service` in your user data script + (by running `systemctl start td-agent-bit.service` after all config files + have been created), and if you fail to do so logs will not be shipped.