openstack-ansible-ops/osquery/installOSquery.yml
Kevin Carter 271ff6a09c Add project directory to overlay inventories
The use of an overlay inventory has now been added to a stand alone
directory which should help deployers understand how this could work
within their environments. Inventory configuration has been updated to
show this working in the various projects that have tests and could
benefit from an overlay inventory.

Change-Id: I1681fce160b43e9127851f06ae05ff5eaabe852f
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
2019-01-16 22:25:11 +00:00

112 lines
3.1 KiB
YAML

---
# Copyright 2018, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Get osquery facts
hosts: kolide-fleet_all[0]
become: true
vars_files:
- vars/variables.yml
tags:
- always
environment: "{{ deployment_environment_variables | default({}) }}"
gather_facts: "{{ osa_gather_facts | default(True) }}"
tasks:
- name: create osquery dir
file:
path: "{{ item }}"
state: directory
with_items:
- /etc/osquery
- name: Retrieve Enrollment Token
command: /usr/local/bin/fleetctl get enroll-secret
changed_when: false
register: _enrollment_token
- name: Set kolide fleet enrollment token fact
set_fact:
kolide_fleet_enroll_secret: "{{ _enrollment_token.stdout }}"
- name: Write enroll secret
copy:
dest: "{{ osquery_enroll_secret_file }}"
content: "{{ kolide_fleet_enroll_secret }}"
mode: "0640"
- name: Fetch Certificates
fetch:
flat: yes
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "0600"
with_items:
- src: "{{ kolide_fleet_ssl_cert }}"
dest: "/tmp/{{ kolide_fleet_ssl_cert | basename }}"
- src: "{{ kolide_fleet_ssl_key }}"
dest: "/tmp/{{ kolide_fleet_ssl_key | basename }}"
- src: "{{ osquery_enroll_secret_file }}"
dest: "/tmp/{{ osquery_enroll_secret_file | basename }}"
- name: Install osquery
hosts: "osquery_all"
become: true
vars_files:
- vars/variables.yml
environment: "{{ deployment_environment_variables | default({}) }}"
gather_facts: "{{ osa_gather_facts | default(True) }}"
pre_tasks:
- name: create osquery dir
file:
path: "{{ item }}"
state: directory
with_items:
- /etc/osquery
- /etc/osquery/ssl
- name: Copy certifactes over
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "0640"
with_items:
- dest: "{{ kolide_fleet_ssl_cert }}"
src: "/tmp/{{ kolide_fleet_ssl_cert | basename }}"
- dest: "{{ kolide_fleet_ssl_key }}"
src: "/tmp/{{ kolide_fleet_ssl_key | basename }}"
- dest: "{{ osquery_enroll_secret_file }}"
src: "/tmp/{{ osquery_enroll_secret_file | basename }}"
post_tasks:
- name: Cleanup certifactes
file:
dest: "{{ item }}"
state: "absent"
delegate_to: localhost
run_once: true
with_items:
- "/tmp/{{ kolide_fleet_ssl_cert | basename }}"
- "/tmp/{{ kolide_fleet_ssl_key | basename }}"
- "/tmp/{{ osquery_enroll_secret_file | basename }}"
roles:
- role: "osquery"