diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index 8ee1f76..0af934b 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -17,9 +17,9 @@ jobs: strategy: matrix: ansible: - - stable-2.11 - stable-2.12 - stable-2.13 + - stable-2.14 - devel runs-on: ubuntu-latest steps: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 972f04c..349c90c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,19 @@ Grafana.Grafana Release Notes .. contents:: Topics +v1.1.0 +====== + +Release Summary +--------------- + +Added Role to deploy Grafana Agent on linux hosts + +Major Changes +------------- + +- Added Role for Grafana Agent + v1.0.5 ====== diff --git a/README.md b/README.md index 0504777..a87db8c 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ We plan to regularly release new minor or bugfix versions once new features or b Releasing the current major version on GitHub happens from the `main` branch by the [GitHub Release Workflow](https://github.com/grafana/grafana-ansible-collection/blob/main/.github/workflows/release.yml) Before the [GitHub Release Workflow](https://github.com/grafana/grafana-ansible-collection/blob/main/.github/workflows/release.yml) is run, Contributors should push the new version on Ansible Galaxy Manually. -We currently are not planning any deprecations or new major releases. The current landscape includes minor version updates for Module's documentation in 1.0.6. +We currently are not planning any deprecations or new major releases. The current landscape includes minor version updates for Module's documentation in 1.1.1. ## Code of Conduct This collection follows the Ansible project's [Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html). Please read and familiarize yourself with this doc diff --git a/changelogs/.plugin-cache.yaml b/changelogs/.plugin-cache.yaml index a90b1e5..e2166c2 100644 --- a/changelogs/.plugin-cache.yaml +++ b/changelogs/.plugin-cache.yaml @@ -53,4 +53,4 @@ plugins: shell: {} strategy: {} vars: {} -version: 1.0.5 +version: 1.1.0 diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index a973581..0386a5e 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -69,3 +69,9 @@ releases: - Added Note to datasource and dashboard module about not supporting Idempotency release_summary: Add Note to modules which don't support Idempotency release_date: '2022-11-10' + 1.1.0: + changes: + major_changes: + - Added Role for Grafana Agent + release_summary: Added Role to deploy Grafana Agent on linux hosts + release_date: '2022-11-17' diff --git a/galaxy.yml b/galaxy.yml index c117f46..16b49fd 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,6 +1,6 @@ namespace: grafana name: grafana -version: 1.0.5 +version: 1.1.0 readme: README.md authors: - Grafana Labs diff --git a/roles/grafana_agent/defaults/main.yml b/roles/grafana_agent/defaults/main.yml new file mode 100644 index 0000000..13a060e --- /dev/null +++ b/roles/grafana_agent/defaults/main.yml @@ -0,0 +1,20 @@ +install_unzip: true +update_package_cache: yes +agent_version: 0.29.0 +linux_architecture: linux-amd64 +agent_binary_location: /usr/local/bin +agent_config_location: /etc/grafana +agent_config_local_path: agent-config.yml + +systemd_service_state: restarted +systemd_config: | + [Unit] + Description=Grafana Agent + + [Service] + User=grafana-agent + ExecStart={{ agent_binary_location }}/agent-{{ linux_architecture }} --config.file={{ agent_config_location }}/agent-config.yaml + Restart=always + + [Install] + WantedBy=multi-user.target \ No newline at end of file diff --git a/roles/grafana_agent/meta/main.yml b/roles/grafana_agent/meta/main.yml new file mode 100644 index 0000000..c99271d --- /dev/null +++ b/roles/grafana_agent/meta/main.yml @@ -0,0 +1,25 @@ +--- +dependencies: [] + +galaxy_info: + role_name: grafana_agent + author: Ishan Jain + description: Ansible Role to deploy Grafana Agent on Linux hosts. + license: "GPL-3.0-or-later" + min_ansible_version: "2.11" + platforms: + - name: Fedora + versions: + - "all" + - name: Debian + versions: + - "all" + - name: Ubuntu + versions: + - "all" + - name: EL + versions: + - "all" + galaxy_tags: + - grafana + - observability \ No newline at end of file diff --git a/roles/grafana_agent/tasks/main.yml b/roles/grafana_agent/tasks/main.yml new file mode 100644 index 0000000..0c5752c --- /dev/null +++ b/roles/grafana_agent/tasks/main.yml @@ -0,0 +1,59 @@ +- name: Install unzip on Ubuntu/Debian + ansible.builtin.apt: + name: unzip + state: present + update_cache: "{{ update_package_cache }}" + when: install_unzip | bool and (ansible_distribution == "Ubuntu" or ansible_distribution == "Debian") + +- name: Install unzip on Fedora/CentOS + ansible.builtin.dnf: + name: unzip + state: latest + update_cache: "{{ update_package_cache }}" + when: install_unzip | bool and (ansible_distribution == "Fedora" or ansible_distribution == "CentOS") + +- name: Download Grafana Agent binary from GitHub + ansible.builtin.get_url: + url: "https://github.com/grafana/agent/releases/download/v{{ agent_version }}/agent-{{ linux_architecture }}.zip" + dest: "/tmp/agent-linux.zip" + mode: '0644' + +- name: Unarchive the Grafana Agent binary + ansible.builtin.unarchive: + src: "/tmp/agent-linux.zip" + dest: "{{ agent_binary_location }}" + remote_src: yes + mode: '0755' + +- name: Create directory for Grafana Agent Configuration file + ansible.builtin.file: + path: "{{ agent_config_location }}" + state: directory + mode: '0755' + +- name: Create configuration file for Grafana Agent + ansible.builtin.copy: + src: "{{ agent_config_local_path }}" + dest: "{{ agent_config_location }}/agent-config.yaml" + +- name: Add user 'grafana-agent' + ansible.builtin.user: + name: grafana-agent + create_home: no + shell: /bin/false + +- name: Create service file for Grafana Agent + ansible.builtin.copy: + dest: "/etc/systemd/system/grafana-agent.service" + content: "{{ systemd_config }}" + +- name: Start Grafana Agent service + ansible.builtin.systemd: + daemon_reload: yes + name: grafana-agent + enabled: yes + state: "{{ systemd_service_state }}" + +- name: Checking grafana-agent service status + ansible.builtin.shell: + cmd: systemctl is-active grafana-agent \ No newline at end of file