Skip to content

Commit

Permalink
linter fixes - bump min ansible to 2.9 to have fqcn builtin tasks.
Browse files Browse the repository at this point in the history
  • Loading branch information
deekayen committed May 5, 2022
1 parent a6735c3 commit 5bc6097
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 38 deletions.
6 changes: 3 additions & 3 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
# See http://docs.ansible.com/playbooks_intro.html for more information about handlers.

- name: restart al-agent
service:
ansible.builtin.service:
name: al-agent
state: restarted

- name: reload syslog-ng
service:
ansible.builtin.service:
name: syslog-ng
state: reloaded

- name: restart rsyslog
service:
ansible.builtin.service:
name: rsyslog
state: restarted
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ galaxy_info:
author: Craig Davis
description: Configure and Install Alert Logic Agents.
license: Apache
min_ansible_version: 2.1
min_ansible_version: 2.9
issue_tracker_url: https://github.com/deekayen/al-agents-ansible-playbooks/issues
platforms:
- name: Debian
Expand Down
10 changes: 5 additions & 5 deletions tasks/_linux.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---

- name: Include Ansible OS family variables
include_vars: "{{ ansible_os_family }}.yml"
ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
tags: always

- name: Include Agent installation file
include: install_agent.yml
tags: [install_agent]

- name: Test for Agent Provisioned
stat:
ansible.builtin.stat:
path: /var/alertlogic/etc/host_key.pem
register: agent_provisioned
ignore_errors: True
ignore_errors: true
tags:
- configure_al_agent
- provision_al_agent
Expand All @@ -34,9 +34,9 @@
tags: [selinux]

- name: Start the Alert Logic Agent service
service:
ansible.builtin.service:
name: al-agent
state: started
enabled: yes
enabled: true
tags: install_al_agent
when: not al_agent_for_imaging
2 changes: 1 addition & 1 deletion tasks/_rsyslog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
notify:
- restart rsyslog
tags: rsyslog
template:
ansible.builtin.template:
src: templates/etc/rsyslog/alertlogic.conf
dest: /etc/rsyslog.d/alertlogic.conf
owner: root
Expand Down
4 changes: 2 additions & 2 deletions tasks/_syslog_ng.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

- name: Insert/Update syslog-ng.conf for inclusion of alertlogic.conf
lineinfile:
ansible.builtin.lineinfile:
dest: /etc/syslog-ng/syslog-ng.conf
regexp: /etc/syslog-ng/conf.d/alertlogic.conf
line: "include '/etc/syslog-ng/conf.d/alertlogic.conf';"
Expand All @@ -14,7 +14,7 @@
notify:
- reload syslog-ng
tags: syslog_ng
template:
ansible.builtin.template:
src: templates/etc/syslog-ng/alertlogic.conf
dest: /etc/syslog-ng/conf.d/alertlogic.conf
owner: root
Expand Down
18 changes: 9 additions & 9 deletions tasks/_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,42 @@
register: al_agent_skip_provision

- name: Set Windows facts
set_fact:
ansible.builtin.set_fact:
al_agent_windows_options: []

# SENSOR_HOST, SENSOR_PORT, USE_PROXY, PROV_NOW, PROV_KEY, PROV_ONLY, INSTALL_ONLY
- name: Set Windows fact for imaging installation "INSTALL_ONLY"
set_fact:
ansible.builtin.set_fact:
al_agent_windows_options: "{{ al_agent_windows_options + [ \"INSTALL_ONLY=1\" ] }}"
when: al_agent_skip_provision.stat.exists or al_agent_for_imaging

- name: Set Windows fact for imaging installation "PROV_NOW"
set_fact:
ansible.builtin.set_fact:
al_agent_windows_options: "{{ al_agent_windows_options + [ \"PROV_NOW=0\" ] }}"
when: al_agent_skip_provision.stat.exists or al_agent_for_imaging

- name: Set Windows fact for use of proxy url
set_fact:
ansible.builtin.set_fact:
al_agent_windows_options: "{{ al_agent_windows_options + [ \"USE_PROXY=\" + al_agent_proxy_url ] }}"
when: al_agent_proxy_url is defined and not al_agent_skip_provision.stat.exists and not al_agent_for_imaging

- name: Set Windows fact for single point of egress host's ip
set_fact:
ansible.builtin.set_fact:
al_agent_windows_options: "{{ al_agent_windows_options + [ \"SENSOR_HOST=\" + al_agent_egress_host ] }}"
when: al_agent_egress_host is defined and not al_agent_skip_provision.stat.exists and not al_agent_for_imaging

- name: Set Windows fact for single point of egress port (default is 443)
set_fact:
ansible.builtin.set_fact:
al_agent_windows_options: "{{ al_agent_windows_options + [ \"SENSOR_PORT=\" + al_agent_egress_port ] }}"
when: al_agent_egress_port is defined and not al_agent_skip_provision.stat.exists and not al_agent_for_imaging

- name: Set Windows fact for use of a registration key
set_fact:
ansible.builtin.set_fact:
al_agent_windows_options: "{{ al_agent_windows_options + [ \"PROV_KEY=\" + al_agent_registration_key ] }}"
when: not al_agent_skip_provision.stat.exists and al_agent_registration_key is defined and not al_agent_for_imaging

- name: Join all Windows optional facts as a single variable
set_fact:
ansible.builtin.set_fact:
al_agent_windows: "{{ al_agent_windows_options | join(' ') }}"

- name: Set Windows TEMP directory
Expand All @@ -62,7 +62,7 @@
force: false

- name: Set Windows debug
debug:
ansible.builtin.debug:
var: al_agent_windows

- name: Install Alert Logic Agent on Windows
Expand Down
10 changes: 5 additions & 5 deletions tasks/configure_agent.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
---

- name: Set Linux optional configs facts
set_fact:
ansible.builtin.set_fact:
al_agent_configure_options: ""

- name: Set Linux optional configs fact for using proxy
set_fact:
ansible.builtin.set_fact:
al_agent_configure_options: "{{ al_agent_configure_options }} --proxy {{ al_agent_proxy_url }}"
when: al_agent_proxy_url is defined

- name: Set Linux optional configs fact for egress host and port
set_fact: al_agent_configure_options="{{ al_agent_configure_options }}
ansible.builtin.set_fact: al_agent_configure_options="{{ al_agent_configure_options }}
--host {{ al_agent_egress_host }}
--port {{ al_agent_egress_port }}"
when: al_agent_egress_port is defined and al_agent_egress_host is defined

- name: Set Linux optional configs fact for egress host only
set_fact:
ansible.builtin.set_fact:
al_agent_configure_options: "{{ al_agent_configure_options }} --host {{ al_agent_egress_host }}"
when: al_agent_egress_port is defined and al_agent_egress_host is not defined

- name: Configure Alert Logic Agent (optional)
command: "/etc/init.d/al-agent configure {{ al_agent_configure_options }}"
ansible.builtin.command: "/etc/init.d/al-agent configure {{ al_agent_configure_options }}"
tags: configure_al_agent
when: not agent_provisioned.stat.exists
4 changes: 2 additions & 2 deletions tasks/configure_loggers.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---

- name: Test for rsyslog being installed
stat:
ansible.builtin.stat:
path: "/etc/rsyslog.conf"
register: rsyslog_init
tags: rsyslog

- name: Test for syslog-ng being installed
stat:
ansible.builtin.stat:
path: "/etc/init.d/syslog-ng"
register: syslog_ng_init
tags: syslog_ng
Expand Down
6 changes: 3 additions & 3 deletions tasks/install_agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- block:
- name: Install Alert Logic Agent on Debian/Ubuntu
apt:
ansible.builtin.apt:
deb: "{{ al_agent_pkg_url }}"
tags: install_al_agent
register: install_result
Expand All @@ -11,7 +11,7 @@
when: ansible_os_family == "Debian"

- name: Install Alert Logic Agent on CentOS/RHEL
yum:
ansible.builtin.yum:
name: "{{ al_agent_pkg_url }}"
state: present
disable_gpg_check: "{{ disable_gpg_check }}"
Expand All @@ -23,7 +23,7 @@
- ansible_os_family == "RedHat"

- name: Install Alert Logic Agent on CentOS/RHEL/Amazon
package:
ansible.builtin.package:
name: "{{ al_agent_pkg_url }}"
state: present
tags: install_al_agent
Expand Down
8 changes: 4 additions & 4 deletions tasks/provision_agent.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---

- name: Set Linux optional facts
set_fact:
ansible.builtin.set_fact:
al_agent_provision_options: []

- name: Set Linux optional fact for using a registration key
set_fact:
ansible.builtin.set_fact:
al_agent_provision_options: "{{ al_agent_provision_options + [ \"--key \" + al_agent_registration_key ] }}"
when: al_agent_registration_key is defined and al_agent_registration_key != "your_registration_key_here"

- name: Provision Alert Logic Agent
command: "/etc/init.d/al-agent provision {{ al_agent_provision_options | join(' ') }}"
ansible.builtin.command: "/etc/init.d/al-agent provision {{ al_agent_provision_options | join(' ') }}"
notify:
- restart al-agent
tags: provision_al_agent
when: not al_agent_for_imaging and not agent_provisioned.stat.exists and al_agent_provision_options != "[]"

- name: Provision Alert Logic Agent - for Imaging
command: "/etc/init.d/al-agent provision {{ al_agent_provision_options | join(' ') }}"
ansible.builtin.command: "/etc/init.d/al-agent provision {{ al_agent_provision_options | join(' ') }}"
tags: provision_al_agent
when: al_agent_for_imaging and not agent_provisioned.stat.exists and al_agent_provision_options != "[]"
3 changes: 2 additions & 1 deletion vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---

al_agent_initscript: 'rsyslog'
al_agent_pkg_name_arch: "{{ ( ansible_architecture == 'x86_64' ) | ternary('amd64', ansible_architecture) }}"
al_agent_pkg_name_arch: "{{ ( ansible_architecture == 'x86_64' ) | ternary('amd64', ansible_architecture) }}"
al_agent_pkg_name_ext: 'deb'
al_agent_syslog_ng_source: "{{ ( ansible_distribution_major_version >= '7' ) | ternary('s_all', 's_sys') }}"
al_agent_base_url: 'https://scc.alertlogic.net'
Expand Down
3 changes: 2 additions & 1 deletion vars/Suse.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---

al_agent_initscript: 'rsyslog'
al_agent_pkg_name_arch: "{{ ansible_architecture }}"
al_agent_pkg_name_ext: 'rpm'
al_agent_syslog_ng_source: "{{ ( ansible_distribution_major_version >= '6' ) | ternary('s_all', 's_sys') }}"
al_agent_base_url: 'https://scc.alertlogic.net'
al_agent_pkg_name_prefix: 'al-agent-LATEST-1.'
al_agent_pkg_url: "{{ al_agent_base_url }}/software/{{ al_agent_pkg_name_prefix }}{{al_agent_pkg_name_arch}}.{{al_agent_pkg_name_ext}}"
al_agent_pkg_url: "{{ al_agent_base_url }}/software/{{ al_agent_pkg_name_prefix }}{{al_agent_pkg_name_arch}}.{{al_agent_pkg_name_ext}}"
3 changes: 2 additions & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---

### Uncomment for global or place in group/host vars for granular control ###
# al_agent_registration_key: 'your_registration_key_here'
### Uncomment the following when configuring optionals ###
# al_agent_egress_port: '443'
# al_agent_egress_host: ''
# al_agent_proxy_url: ''
al_agent_for_imaging: False
al_agent_for_imaging: false

0 comments on commit 5bc6097

Please sign in to comment.