Skip to content

Commit

Permalink
chore: add verify playbook and more images to test
Browse files Browse the repository at this point in the history
  • Loading branch information
GlauberrBatista committed Nov 29, 2023
1 parent d50552a commit 7b74665
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 11 deletions.
29 changes: 18 additions & 11 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,32 @@ lint: |
set -e
yamllint .
platforms:
# - name: bionic
# image: solita/ubuntu-systemd:18.04
# privileged: true
# command: /sbin/init
- name: bionic
image: geerlingguy/docker-ubuntu1804-ansible:latest
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
pre_build_image: true
- name: focal
image: geerlingguy/docker-ubuntu2004-ansible:latest
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
pre_build_image: true
# command: ${MOLECULE_DOCKER_COMMAND:-""}
# volumes:
# - /sys/fs/cgroup:/sys/fs/cgroup:rw
# cgroupns_mode: host
# privileged: true
# pre_build_image: true
- name: jammy
image: geerlingguy/docker-ubuntu2204-ansible:latest
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
pre_build_image: true
provisioner:
name: ansible
lint:
name: ansible-lint
scenario:
name: default
verifier:
name: ansible
37 changes: 37 additions & 0 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
- hosts: all
roles:
- role: ansible-role-cloudwatch-logs
cw_server_type: onPremise
aws_region: us-east-1
cw_logs_files:
- log_group_name: /var/log/syslog
log_stream_name: '{hostname}-{instance_id}'
timestamp_format: '%b %d %H:%M:%S'
file_path: /var/log/syslog
encoding: utf-8
- log_group_name: /var/log/auth.log
log_stream_name: '{hostname}-{instance_id}'
timestamp_format: '%b %d %H:%M:%S'
file_path: /var/log/auth.log
encoding: utf-8
post_tasks:
- name: Ensure log configurations in place
shell: "grep -q {{ item }} /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent.json"
changed_when: false
with_items: "{{ cw_logs_files|map(attribute='log_group_name')|list }}"

- name: Check agent status
shell: "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a status"
changed_when: false
register: agent_status

- name: Fail if agent not running
fail:
msg: "The CloudWatch agent is not running"
when: "'running' not in agent_status.stdout"

- name: Fail if agent not configured
fail:
msg: "The CloudWatch agent is not running"
when: "'\"configured\"' not in agent_status.stdout"

0 comments on commit 7b74665

Please sign in to comment.