diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml index a068763..4cc61c3 100644 --- a/.github/workflows/molecule.yml +++ b/.github/workflows/molecule.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: distro: ['rockylinux8', 'ubuntu2204', 'debian12'] - scenario: ['carbonapi', 'go-carbon'] + scenario: ['carbonapi', 'gocarbon'] steps: - name: Checkout code diff --git a/README.md b/README.md index 2f96d69..7abf87b 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Collection tested on RockyLinux 8, Debian 12 and Ubuntu 22.04. ## Roles -* [go-carbon](roles/go-carbon/README.md): Install and configure go-carbon +* [gocarbon](roles/gocarbon/README.md): Install and configure go-carbon * [carbonapi](roles/carbonapi/README.md) Install and configure carbonapi @@ -21,7 +21,7 @@ Collection tested on RockyLinux 8, Debian 12 and Ubuntu 22.04. become: true collections: tbauriedel.gographite roles: - - go-carbon + - gocarbon - carbonapi ``` diff --git a/molecule/go-carbon/converge.yml b/molecule/gocarbon/converge.yml similarity index 84% rename from molecule/go-carbon/converge.yml rename to molecule/gocarbon/converge.yml index fbc12ab..a77bb3e 100644 --- a/molecule/go-carbon/converge.yml +++ b/molecule/gocarbon/converge.yml @@ -6,4 +6,4 @@ - tbauriedel.gographite roles: - - go-carbon + - gocarbon diff --git a/molecule/go-carbon/molecule.yml b/molecule/gocarbon/molecule.yml similarity index 94% rename from molecule/go-carbon/molecule.yml rename to molecule/gocarbon/molecule.yml index 97fd603..32cc663 100644 --- a/molecule/go-carbon/molecule.yml +++ b/molecule/gocarbon/molecule.yml @@ -4,7 +4,7 @@ dependency: driver: name: docker platforms: - - name: go-carbon + - name: gocarbon image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest" command: ${MOLECULE_DOCKER_COMMAND:-""} cgroupns_mode: host diff --git a/molecule/go-carbon/verify.yml b/molecule/gocarbon/verify.yml similarity index 100% rename from molecule/go-carbon/verify.yml rename to molecule/gocarbon/verify.yml diff --git a/roles/go-carbon/README.md b/roles/go-carbon/README.md deleted file mode 100644 index 55cfb1b..0000000 --- a/roles/go-carbon/README.md +++ /dev/null @@ -1,117 +0,0 @@ -# tbauriedel.go-carbon - -Installs and configures [go-carbon](https://github.com/go-graphite/go-carbon). - -## Variables - -A detailed documentation can be found inside of the [official go-carbon repo](https://github.com/go-graphite/go-carbon?tab=readme-ov-file#configuration). - -Default variables are defined [here](defaults/main.yml). - -`go_carbon_version`: Version (Default: `0.17.3`) -`go_carbon_storage_dir`: Storage directory (Default: `/var/lib/graphite`) -`go_carbon_group`: Service user (Default: `carbon`) -`go_carbon_user`: Service group (Default: `carbon`) - -`go_carbon_max_cpu`: Max CPU (Default: `1`) -`go_carbon_whisper_workers`: Max workers (Default: `1`) -`go_carbon_cache_max_size`: Max cache size (Default: `1000000`) -`go_carbon_udp_enabled`: Enable udp listener (Default: `true`) -`go_carbon_upd_listen`: UDP listener (Default: `127.0.0.1:2003`) -`go_carbon_tcp_enabled`: Enable TCP listener (Default: `true`) -`go_carbon_tcp_listen`: TCP listener (Default: `127.0.0.1:2003`) -`go_carbon_carbonlink_enabled`: Enable carbonlink listener (Default: `true`) -`go_carbon_carbonlink_listen`: carbonlink listener (Default: `127.0.0.1:7200`) -`go_carbon_pickle_enabled`: Enable pickle listener (Default: `true`) -`go_carbon_pickle_listen`: pickle listener (Default: `127.0.0.1:2004`) -`go_carbon_carbonserver_enabled`: Enable carbonserver (Default: `true`) -`go_carbon_carbonserver_listen`: carbonserver listener: (Default: `127.0.0.1:8080`) - -`go_carbon_logging_file`: Logfile (Default: `/var/log/go-carbon/go-carbon.log`) -`go_carbon_logging_severity`: Log severity (Default: `warn`) - -`go_carbon_extra_conf:` Add some extra custom configuration - -`go_carbon_storage_schemas`: List of storage retentions (Default: [here](defaults/main.yml)) -`go_carbon_storage_schemas.name`: Name of schema -`go_carbon_storage_schemas.pattern`: Pattern that should match -`go_carbon_storage_schemas.retentions`: Retention policy -`go_carbon_storage_schemas.compressed`: Enable compression (Default: `false`) - -`go_carbon_storage_aggregation`: Add storage aggregation - -## Config file - -If you dont add some custom configuration, the go-carbon.conf will look like this. -``` -# -# Ansible managed -# - -[common] -user = "carbon" -graph-prefix = "carbon.agents.{host}" -metric-endpoint = "local" -max-cpu = 1 -metric-interval = "1m0s" - -[whisper] -data-dir = "/var/lib/graphite/whisper/" -schemas-file = "/etc/go-carbon/storage-schemas.conf" -aggregation-file = "" -quotas-file = "" -workers = 1 -max-updates-per-second = 0 -sparse-create = false -physical-size-factor = 0.75 -flock = false -compressed = false -enabled = true -hash-filenames = true -remove-empty-file = false -online-migration = false -online-migration-rate = 5 -online-migration-global-scope = "" - -[cache] -max-size = 1000000 -write-strategy = "max" - -[carbonserver] -listen = "127.0.0.1:8080" -enabled = true - -[udp] -listen = "127.0.0.1:2003" -enabled = true -buffer-size = 0 - -[tcp] -listen = "127.0.0.1:2003" -enabled = true -buffer-size = 0 -compression = "" - -[carbonlink] -listen = "127.0.0.1:7200" -enabled = true -read-timeout = "30s" - -[pickle] -listen = "127.0.0.1:2004" -max-message-size = 67108864 -enabled = true -buffer-size = 0 - - -[[logging]] -logger = "" -file = "/var/log/go-carbon/go-carbon.log" -level = "warn" -encoding = "mixed" -encoding-time = "iso8601" -encoding-duration = "seconds" -sample-tick = "" -sample-initial = 0 -sample-thereafter = 0 -``` diff --git a/roles/go-carbon/defaults/main.yml b/roles/go-carbon/defaults/main.yml deleted file mode 100644 index d024a58..0000000 --- a/roles/go-carbon/defaults/main.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- -go_carbon_version: 0.17.3 - -go_carbon_storage_dir: /var/lib/graphite -go_carbon_group: carbon -go_carbon_user: carbon - -go_carbon_max_cpu: 1 -go_carbon_metric_interval: 1m0s -go_carbon_whisper_workers: 1 -go_carbon_cache_max_size: 1000000 -go_carbon_udp_enabled: 'true' -go_carbon_upd_listen: 127.0.0.1:2003 -go_carbon_tcp_enabled: 'true' -go_carbon_tcp_listen: 127.0.0.1:2003 -go_carbon_carbonlink_enabled: 'true' -go_carbon_carbonlink_listen: 127.0.0.1:7200 -go_carbon_pickle_enabled: 'true' -go_carbon_pickle_listen: 127.0.0.1:2004 -go_carbon_carbonserver_enabled: 'true' -go_carbon_carbonserver_listen: 127.0.0.1:8080 - -go_carbon_logging_file: /var/log/go-carbon/go-carbon.log -go_carbon_logging_severity: warn - -go_carbon_extra_conf: "" - -go_carbon_storage_schemas: - - name: default - pattern: .* - retentions: 60s:30d,1h:5y - compressed: 'false' - -go_carbon_storage_aggregation: "" diff --git a/roles/go-carbon/templates/storage-aggregation.conf.j2 b/roles/go-carbon/templates/storage-aggregation.conf.j2 deleted file mode 100644 index 7fd4bc4..0000000 --- a/roles/go-carbon/templates/storage-aggregation.conf.j2 +++ /dev/null @@ -1,5 +0,0 @@ -{{ ansible_managed | comment }} - -{% if go_carbon_storage_aggregation | length > 0 %} -{{ go_carbon_storage_aggregation }} -{% endif %} \ No newline at end of file diff --git a/roles/go-carbon/vars/Debian.yml b/roles/go-carbon/vars/Debian.yml deleted file mode 100644 index 72e9f36..0000000 --- a/roles/go-carbon/vars/Debian.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -go_carbon_release_package: "https://github.com/go-graphite/go-carbon/releases/download/v{{ go_carbon_version }}/go-carbon_{{ go_carbon_version }}_amd64.deb" diff --git a/roles/go-carbon/vars/RedHat.yml b/roles/go-carbon/vars/RedHat.yml deleted file mode 100644 index d0a4c80..0000000 --- a/roles/go-carbon/vars/RedHat.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -go_carbon_release_package: "https://github.com/go-graphite/go-carbon/releases/download/v{{ go_carbon_version }}/go-carbon-{{ go_carbon_version }}-1.x86_64.rpm" diff --git a/roles/gocarbon/README.md b/roles/gocarbon/README.md new file mode 100644 index 0000000..62cdb0a --- /dev/null +++ b/roles/gocarbon/README.md @@ -0,0 +1,117 @@ +# tbauriedel.gocarbon + +Installs and configures [go-carbon](https://github.com/go-graphite/go-carbon). + +## Variables + +A detailed documentation can be found inside of the [official go-carbon repo](https://github.com/go-graphite/go-carbon?tab=readme-ov-file#configuration). + +Default variables are defined [here](defaults/main.yml). + +`gocarbon_version`: Version (Default: `0.17.3`) +`gocarbon_storage_dir`: Storage directory (Default: `/var/lib/graphite`) +`gocarbon_group`: Service user (Default: `carbon`) +`gocarbon_user`: Service group (Default: `carbon`) + +`gocarbon_max_cpu`: Max CPU (Default: `1`) +`gocarbon_whisper_workers`: Max workers (Default: `1`) +`gocarbon_cache_max_size`: Max cache size (Default: `1000000`) +`gocarbon_udp_enabled`: Enable udp listener (Default: `true`) +`gocarbon_upd_listen`: UDP listener (Default: `127.0.0.1:2003`) +`gocarbon_tcp_enabled`: Enable TCP listener (Default: `true`) +`gocarbon_tcp_listen`: TCP listener (Default: `127.0.0.1:2003`) +`gocarbon_carbonlink_enabled`: Enable carbonlink listener (Default: `true`) +`gocarbon_carbonlink_listen`: carbonlink listener (Default: `127.0.0.1:7200`) +`gocarbon_pickle_enabled`: Enable pickle listener (Default: `true`) +`gocarbon_pickle_listen`: pickle listener (Default: `127.0.0.1:2004`) +`gocarbon_carbonserver_enabled`: Enable carbonserver (Default: `true`) +`gocarbon_carbonserver_listen`: carbonserver listener: (Default: `127.0.0.1:8080`) + +`gocarbon_logging_file`: Logfile (Default: `/var/log/go-carbon/go-carbon.log`) +`gocarbon_logging_severity`: Log severity (Default: `warn`) + +`gocarbon_extra_conf:` Add some extra custom configuration + +`gocarbon_storage_schemas`: List of storage retentions (Default: [here](defaults/main.yml)) +`gocarbon_storage_schemas.name`: Name of schema +`gocarbon_storage_schemas.pattern`: Pattern that should match +`gocarbon_storage_schemas.retentions`: Retention policy +`gocarbon_storage_schemas.compressed`: Enable compression (Default: `false`) + +`gocarbon_storage_aggregation`: Add storage aggregation + +## Config file + +If you dont add some custom configuration, the go-carbon.conf will look like this. +``` +# +# Ansible managed +# + +[common] +user = "carbon" +graph-prefix = "carbon.agents.{host}" +metric-endpoint = "local" +max-cpu = 1 +metric-interval = "1m0s" + +[whisper] +data-dir = "/var/lib/graphite/whisper/" +schemas-file = "/etc/go-carbon/storage-schemas.conf" +aggregation-file = "" +quotas-file = "" +workers = 1 +max-updates-per-second = 0 +sparse-create = false +physical-size-factor = 0.75 +flock = false +compressed = false +enabled = true +hash-filenames = true +remove-empty-file = false +online-migration = false +online-migration-rate = 5 +online-migration-global-scope = "" + +[cache] +max-size = 1000000 +write-strategy = "max" + +[carbonserver] +listen = "127.0.0.1:8080" +enabled = true + +[udp] +listen = "127.0.0.1:2003" +enabled = true +buffer-size = 0 + +[tcp] +listen = "127.0.0.1:2003" +enabled = true +buffer-size = 0 +compression = "" + +[carbonlink] +listen = "127.0.0.1:7200" +enabled = true +read-timeout = "30s" + +[pickle] +listen = "127.0.0.1:2004" +max-message-size = 67108864 +enabled = true +buffer-size = 0 + + +[[logging]] +logger = "" +file = "/var/log/go-carbon/go-carbon.log" +level = "warn" +encoding = "mixed" +encoding-time = "iso8601" +encoding-duration = "seconds" +sample-tick = "" +sample-initial = 0 +sample-thereafter = 0 +``` diff --git a/roles/gocarbon/defaults/main.yml b/roles/gocarbon/defaults/main.yml new file mode 100644 index 0000000..3024c5a --- /dev/null +++ b/roles/gocarbon/defaults/main.yml @@ -0,0 +1,34 @@ +--- +gocarbon_version: 0.17.3 + +gocarbon_storage_dir: /var/lib/graphite +gocarbon_group: carbon +gocarbon_user: carbon + +gocarbon_max_cpu: 1 +gocarbon_metric_interval: 1m0s +gocarbon_whisper_workers: 1 +gocarbon_cache_max_size: 1000000 +gocarbon_udp_enabled: "true" +gocarbon_upd_listen: 127.0.0.1:2003 +gocarbon_tcp_enabled: "true" +gocarbon_tcp_listen: 127.0.0.1:2003 +gocarbon_carbonlink_enabled: "true" +gocarbon_carbonlink_listen: 127.0.0.1:7200 +gocarbon_pickle_enabled: "true" +gocarbon_pickle_listen: 127.0.0.1:2004 +gocarbon_carbonserver_enabled: "true" +gocarbon_carbonserver_listen: 127.0.0.1:8080 + +gocarbon_logging_file: /var/log/go-carbon/go-carbon.log +gocarbon_logging_severity: warn + +gocarbon_extra_conf: "" + +gocarbon_storage_schemas: + - name: default + pattern: .* + retentions: 60s:30d,1h:5y + compressed: "false" + +gocarbon_storage_aggregation: "" diff --git a/roles/go-carbon/handlers/main.yml b/roles/gocarbon/handlers/main.yml similarity index 100% rename from roles/go-carbon/handlers/main.yml rename to roles/gocarbon/handlers/main.yml diff --git a/roles/go-carbon/tasks/main.yml b/roles/gocarbon/tasks/main.yml similarity index 100% rename from roles/go-carbon/tasks/main.yml rename to roles/gocarbon/tasks/main.yml diff --git a/roles/go-carbon/tasks/setup.yml b/roles/gocarbon/tasks/setup.yml similarity index 77% rename from roles/go-carbon/tasks/setup.yml rename to roles/gocarbon/tasks/setup.yml index 68589ba..bb045cd 100644 --- a/roles/go-carbon/tasks/setup.yml +++ b/roles/gocarbon/tasks/setup.yml @@ -1,9 +1,9 @@ --- - name: Fetch package from source ansible.builtin.get_url: - url: "{{ go_carbon_release_package }}" + url: "{{ gocarbon_release_package }}" dest: /tmp - mode: '0755' + mode: "0755" timeout: 60 register: _fetched_source changed_when: false @@ -23,25 +23,25 @@ - name: Ensure storage-dir exists ansible.builtin.file: - path: "{{ go_carbon_storage_dir }}" + path: "{{ gocarbon_storage_dir }}" state: directory - mode: '0755' - owner: "{{ go_carbon_user }}" - group: "{{ go_carbon_group }}" + mode: "0755" + owner: "{{ gocarbon_user }}" + group: "{{ gocarbon_group }}" - name: Ensure whisper-dir exists ansible.builtin.file: - path: "{{ go_carbon_storage_dir }}/whisper" + path: "{{ gocarbon_storage_dir }}/whisper" state: directory - mode: '0755' - owner: "{{ go_carbon_user }}" - group: "{{ go_carbon_group }}" + mode: "0755" + owner: "{{ gocarbon_user }}" + group: "{{ gocarbon_group }}" - name: Place go-carbon configuration ansible.builtin.template: src: go-carbon.conf.j2 dest: /etc/go-carbon/go-carbon.conf - mode: '0644' + mode: "0644" owner: root group: root notify: Restart go-carbon @@ -50,7 +50,7 @@ ansible.builtin.template: src: storage-schemas.conf.j2 dest: /etc/go-carbon/storage-schemas.conf - mode: '0644' + mode: "0644" owner: root group: root notify: Restart go-carbon @@ -59,7 +59,7 @@ ansible.builtin.template: src: storage-aggregation.conf.j2 dest: /etc/go-carbon/storage-aggregation.conf - mode: '0644' + mode: "0644" owner: root group: root notify: Restart go-carbon diff --git a/roles/go-carbon/templates/go-carbon.conf.j2 b/roles/gocarbon/templates/go-carbon.conf.j2 similarity index 51% rename from roles/go-carbon/templates/go-carbon.conf.j2 rename to roles/gocarbon/templates/go-carbon.conf.j2 index 1b27846..1ff7cbf 100644 --- a/roles/go-carbon/templates/go-carbon.conf.j2 +++ b/roles/gocarbon/templates/go-carbon.conf.j2 @@ -1,22 +1,22 @@ {{ ansible_managed | comment }} [common] -user = "{{ go_carbon_user }}" +user = "{{ gocarbon_user }}" graph-prefix = "carbon.agents.{host}" metric-endpoint = "local" -max-cpu = {{ go_carbon_max_cpu }} -metric-interval = "{{ go_carbon_metric_interval }}" +max-cpu = {{ gocarbon_max_cpu }} +metric-interval = "{{ gocarbon_metric_interval }}" [whisper] -data-dir = "{{ go_carbon_storage_dir }}/whisper/" +data-dir = "{{ gocarbon_storage_dir }}/whisper/" schemas-file = "/etc/go-carbon/storage-schemas.conf" -{% if go_carbon_storage_aggregation | length > 0 %} +{% if gocarbon_storage_aggregation | length > 0 %} aggregation-file = "/etc/go-carbon/storage-aggregation.conf" {% else %} aggregation-file = "" {% endif %} quotas-file = "" -workers = {{ go_carbon_whisper_workers }} +workers = {{ gocarbon_whisper_workers }} max-updates-per-second = 0 sparse-create = false physical-size-factor = 0.75 @@ -30,43 +30,43 @@ online-migration-rate = 5 online-migration-global-scope = "" [cache] -max-size = {{ go_carbon_cache_max_size }} +max-size = {{ gocarbon_cache_max_size }} write-strategy = "max" [carbonserver] -listen = "{{ go_carbon_carbonserver_listen }}" -enabled = {{ go_carbon_carbonserver_enabled }} +listen = "{{ gocarbon_carbonserver_listen }}" +enabled = {{ gocarbon_carbonserver_enabled }} [udp] -listen = "{{ go_carbon_upd_listen }}" -enabled = {{ go_carbon_udp_enabled }} +listen = "{{ gocarbon_upd_listen }}" +enabled = {{ gocarbon_udp_enabled }} buffer-size = 0 [tcp] -listen = "{{ go_carbon_tcp_listen }}" -enabled = {{ go_carbon_tcp_enabled }} +listen = "{{ gocarbon_tcp_listen }}" +enabled = {{ gocarbon_tcp_enabled }} buffer-size = 0 compression = "" [carbonlink] -listen = "{{ go_carbon_carbonlink_listen }}" -enabled = {{ go_carbon_carbonlink_enabled }} +listen = "{{ gocarbon_carbonlink_listen }}" +enabled = {{ gocarbon_carbonlink_enabled }} read-timeout = "30s" [pickle] -listen = "{{ go_carbon_pickle_listen }}" +listen = "{{ gocarbon_pickle_listen }}" max-message-size = 67108864 -enabled = {{ go_carbon_pickle_enabled }} +enabled = {{ gocarbon_pickle_enabled }} buffer-size = 0 -{% if go_carbon_extra_conf | length > 0 %} -{{ go_carbon_extra_conf }} +{% if gocarbon_extra_conf | length > 0 %} +{{ gocarbon_extra_conf }} {% endif %} [[logging]] logger = "" -file = "{{ go_carbon_logging_file }}" -level = "{{ go_carbon_logging_severity }}" +file = "{{ gocarbon_logging_file }}" +level = "{{ gocarbon_logging_severity }}" encoding = "mixed" encoding-time = "iso8601" encoding-duration = "seconds" diff --git a/roles/gocarbon/templates/storage-aggregation.conf.j2 b/roles/gocarbon/templates/storage-aggregation.conf.j2 new file mode 100644 index 0000000..91ac670 --- /dev/null +++ b/roles/gocarbon/templates/storage-aggregation.conf.j2 @@ -0,0 +1,5 @@ +{{ ansible_managed | comment }} + +{% if gocarbon_storage_aggregation | length > 0 %} +{{ gocarbon_storage_aggregation }} +{% endif %} \ No newline at end of file diff --git a/roles/go-carbon/templates/storage-schemas.conf.j2 b/roles/gocarbon/templates/storage-schemas.conf.j2 similarity index 80% rename from roles/go-carbon/templates/storage-schemas.conf.j2 rename to roles/gocarbon/templates/storage-schemas.conf.j2 index f43229f..4557079 100644 --- a/roles/go-carbon/templates/storage-schemas.conf.j2 +++ b/roles/gocarbon/templates/storage-schemas.conf.j2 @@ -1,6 +1,6 @@ {{ ansible_managed | comment }} -{% for schema in go_carbon_storage_schemas %} +{% for schema in gocarbon_storage_schemas %} [{{ schema.name }}] pattern = {{ schema.pattern }} retentions = {{ schema.retentions }} diff --git a/roles/gocarbon/vars/Debian.yml b/roles/gocarbon/vars/Debian.yml new file mode 100644 index 0000000..4fe325a --- /dev/null +++ b/roles/gocarbon/vars/Debian.yml @@ -0,0 +1,2 @@ +--- +gocarbon_release_package: "https://github.com/go-graphite/go-carbon/releases/download/v{{ gocarbon_version }}/go-carbon_{{ gocarbon_version }}_amd64.deb" diff --git a/roles/gocarbon/vars/RedHat.yml b/roles/gocarbon/vars/RedHat.yml new file mode 100644 index 0000000..8d8f720 --- /dev/null +++ b/roles/gocarbon/vars/RedHat.yml @@ -0,0 +1,2 @@ +--- +gocarbon_release_package: "https://github.com/go-graphite/go-carbon/releases/download/v{{ gocarbon_version }}/go-carbon-{{ gocarbon_version }}-1.x86_64.rpm"