add awslogs role
authorJustin Wind <j.wind@partner.samsung.com>
Thu, 16 Mar 2017 17:38:31 +0000 (10:38 -0700)
committerJustin Wind <j.wind@partner.samsung.com>
Thu, 16 Mar 2017 17:38:31 +0000 (10:38 -0700)
roles/awslogs/files/awslogs.conf [new file with mode: 0644]
roles/awslogs/files/logging.conf [new file with mode: 0644]
roles/awslogs/handlers/main.yml [new file with mode: 0644]
roles/awslogs/tasks/main.yml [new file with mode: 0644]
roles/awslogs/templates/awscli.conf.j2 [new file with mode: 0644]

diff --git a/roles/awslogs/files/awslogs.conf b/roles/awslogs/files/awslogs.conf
new file mode 100644 (file)
index 0000000..e2cac13
--- /dev/null
@@ -0,0 +1,4 @@
+[general]
+state_file = /var/lib/awslogs/agent-state
+logging_config_file = /etc/awslogs/logging.conf
+use_gzip_http_content_encoding = true
diff --git a/roles/awslogs/files/logging.conf b/roles/awslogs/files/logging.conf
new file mode 100644 (file)
index 0000000..f41cfb6
--- /dev/null
@@ -0,0 +1,39 @@
+[loggers]
+keys=root,cwlogs,reader,publisher
+
+[handlers]
+keys=consoleHandler
+
+[formatters]
+keys=simpleFormatter
+
+[logger_root]
+level=WARNING
+handlers=consoleHandler
+
+[logger_cwlogs]
+level=WARNING
+handlers=consoleHandler
+qualname=cwlogs.push
+propagate=0
+
+[logger_reader]
+level=ERROR
+handlers=consoleHandler
+qualname=cwlogs.push.reader
+propagate=0
+
+[logger_publisher]
+level=WARNING
+handlers=consoleHandler
+qualname=cwlogs.push.publisher
+propagate=0
+
+[handler_consoleHandler]
+class=logging.StreamHandler
+level=INFO
+formatter=simpleFormatter
+args=(sys.stderr,)
+
+[formatter_simpleFormatter]
+format=%(asctime)s - %(name)s - %(levelname)s - %(process)d - %(threadName)s - %(message)s
diff --git a/roles/awslogs/handlers/main.yml b/roles/awslogs/handlers/main.yml
new file mode 100644 (file)
index 0000000..e90da80
--- /dev/null
@@ -0,0 +1,5 @@
+---
+- name: restart awslogs
+  service:
+    name: awslogs
+    state: restarted
diff --git a/roles/awslogs/tasks/main.yml b/roles/awslogs/tasks/main.yml
new file mode 100644 (file)
index 0000000..7fb354d
--- /dev/null
@@ -0,0 +1,41 @@
+---
+- ec2_facts:
+
+- name: Install awslogs package
+  with_items:
+  - awslogs
+  yum:
+    name: "{{ item }}"
+    state: latest
+
+- name: Install awslogs templates
+  with_items:
+  - awscli.conf
+  template:
+    src: "{{ item }}.j2"
+    dest: /etc/awslogs/{{ item }}
+    mode: "0644"
+    owner: root
+    group: root
+  notify:
+  - restart awslogs
+
+- name: Install awslogs configs
+  with_items:
+  - awslogs.conf
+  - logging.conf
+  copy:
+    src: "{{ item }}"
+    dest: /etc/awslogs/{{ item }}
+    mode: "0644"
+    owner: root
+    group: root
+  notify:
+  - restart awslogs
+
+- name: enable awslogs
+  service:
+    name: awslogs
+    enabled: yes
+  notify:
+  - restart awslogs
diff --git a/roles/awslogs/templates/awscli.conf.j2 b/roles/awslogs/templates/awscli.conf.j2
new file mode 100644 (file)
index 0000000..9c7137b
--- /dev/null
@@ -0,0 +1,4 @@
+[plugins]
+cwlogs = cwlogs
+[default]
+region = {{ ansible_ec2_placement_region }}