diff --git a/playbook/linux/elastic/install-winlogbeat.yml b/playbook/linux/elastic/install-winlogbeat.yml new file mode 100644 index 0000000..ead71a4 --- /dev/null +++ b/playbook/linux/elastic/install-winlogbeat.yml @@ -0,0 +1,16 @@ +--- + +- name: Install WinLogBeat + hosts: elasticClients + + tasks: + - name: Install WinLogBeat + become: true + include_role: + name: luther38.winlogbeat + vars: + version: 7.0.0 + kibana_host: 172.20.0.142 + elasticsearch_hosts: '["172.20.0.142:9200"]' + + diff --git a/roles/luther38.logstash/README.md b/roles/luther38.logstash/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/luther38.logstash/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/luther38.logstash/defaults/main.yml b/roles/luther38.logstash/defaults/main.yml new file mode 100644 index 0000000..503a7ab --- /dev/null +++ b/roles/luther38.logstash/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for luther38.logstash \ No newline at end of file diff --git a/roles/luther38.logstash/handlers/main.yml b/roles/luther38.logstash/handlers/main.yml new file mode 100644 index 0000000..f6a1d47 --- /dev/null +++ b/roles/luther38.logstash/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for luther38.logstash \ No newline at end of file diff --git a/roles/luther38.logstash/meta/main.yml b/roles/luther38.logstash/meta/main.yml new file mode 100644 index 0000000..5d50bf4 --- /dev/null +++ b/roles/luther38.logstash/meta/main.yml @@ -0,0 +1,60 @@ +galaxy_info: + author: your name + description: your description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: license (GPLv2, CC-BY, etc) + + min_ansible_version: 2.4 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # Optionally specify the branch Galaxy will use when accessing the GitHub + # repo for this role. During role install, if no tags are available, + # Galaxy will use this branch. During import Galaxy will access files on + # this branch. If Travis integration is configured, only notifications for this + # branch will be accepted. Otherwise, in all cases, the repo's default branch + # (usually master) will be used. + #github_branch: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. \ No newline at end of file diff --git a/roles/luther38.logstash/tasks/main.yml b/roles/luther38.logstash/tasks/main.yml new file mode 100644 index 0000000..9277f44 --- /dev/null +++ b/roles/luther38.logstash/tasks/main.yml @@ -0,0 +1,2 @@ +--- +# tasks file for luther38.logstash \ No newline at end of file diff --git a/roles/luther38.logstash/tests/inventory b/roles/luther38.logstash/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/luther38.logstash/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/luther38.logstash/tests/test.yml b/roles/luther38.logstash/tests/test.yml new file mode 100644 index 0000000..f869efb --- /dev/null +++ b/roles/luther38.logstash/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - luther38.logstash \ No newline at end of file diff --git a/roles/luther38.logstash/vars/main.yml b/roles/luther38.logstash/vars/main.yml new file mode 100644 index 0000000..29d57d6 --- /dev/null +++ b/roles/luther38.logstash/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for luther38.logstash \ No newline at end of file diff --git a/roles/luther38.metricbeat/tasks/main.yml b/roles/luther38.metricbeat/tasks/main.yml index ff1f622..624d141 100644 --- a/roles/luther38.metricbeat/tasks/main.yml +++ b/roles/luther38.metricbeat/tasks/main.yml @@ -6,5 +6,5 @@ include: ubuntu.yml - name: Install Metricbeat on Windows - when: ansible_distribution == 'Windows' + when: ansible_os_family == 'Windows' include: windows.yml diff --git a/roles/luther38.metricbeat/tasks/windows.yml b/roles/luther38.metricbeat/tasks/windows.yml index 715e5b3..ede903b 100644 --- a/roles/luther38.metricbeat/tasks/windows.yml +++ b/roles/luther38.metricbeat/tasks/windows.yml @@ -1,32 +1,62 @@ - +#https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-7.0.0-windows-x86_64.zip # This will install metricbeat on a windows host. --- -- name: make temp folder +- name: make tmp folder win_file: path: c:\tmp\ state: directory - name: download metricbeat win_get_url: - url: '{{ url_metricbeat }}' - dest: 'C:\temp\metricbeat-{{ version }}.zip' + url: 'https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-{{ version }}-windows-x86_64.zip' + dest: 'C:\tmp\metricbeat-{{ version }}.zip' force: no - name: unzip metricbeat win_unzip: - src: c:\temp\metricbeat-{{ version }}.zip - dest: C:\temp\metricbeat-{{ version }}\ - creates: C:\temp\metricbeat-{{ version }}\ + src: c:\tmp\metricbeat-{{ version }}.zip + dest: C:\tmp\metricbeat-{{ version }}\ + creates: C:\tmp\metricbeat-{{ version }}\ - name: Copy metricbeat-{{ version }} folder - win_command: powershell.exe copy-item -Path 'c:\temp\metricbeat-{{ version }}\heartbeat-{{ version }}-windows-x86_64\' -Filter * -Recurse -Destination 'C:\Program Files\Metricbeat\' + win_command: powershell.exe copy-item -Path 'c:\tmp\metricbeat-{{ version }}\metricbeat-{{ version }}-windows-x86_64\' -Filter * -Recurse -Destination 'C:\Program Files\Metricbeat\' args: creates: C:\Program Files\Metricbeat\ -- name: Update template +- name: Update tmplate win_template: src: metricbeat.j2 dest: C:\Program Files\Metricbeat\metricbeat.yml +- name: Check if metricbeat service is installed + register: service + win_service: + name: metricbeat + +#- debug: var=service + - name: Install Metricbeat service - win_command: powershell.exe -ExecutionPolicy ByPass -File 'C:\Program Files\Metricbeat\install-service-metricbeat.ps1' + when: service.exists == false + win_command: powershell.exe -ExecutionPolicy ByPass -File install-service-metricbeat.ps1 + args: + chdir: C:\program files\metricbeat\ + +- name: check status of metricbeat service + register: service + win_service: + name: metricbeat + +#- debug: var=service + +- name: restart service + when: service.state == 'running' + win_service: + name: metricbeat + state: restarted + +- name: start service + when: service.state == 'stopped' + win_service: + name: metricbeat + state: started + diff --git a/roles/luther38.winlogbeat/README.md b/roles/luther38.winlogbeat/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/luther38.winlogbeat/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/luther38.winlogbeat/defaults/main.yml b/roles/luther38.winlogbeat/defaults/main.yml new file mode 100644 index 0000000..dabf483 --- /dev/null +++ b/roles/luther38.winlogbeat/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for luther38.winlogbeat \ No newline at end of file diff --git a/roles/luther38.winlogbeat/handlers/main.yml b/roles/luther38.winlogbeat/handlers/main.yml new file mode 100644 index 0000000..1359119 --- /dev/null +++ b/roles/luther38.winlogbeat/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for luther38.winlogbeat \ No newline at end of file diff --git a/roles/luther38.winlogbeat/meta/main.yml b/roles/luther38.winlogbeat/meta/main.yml new file mode 100644 index 0000000..5d50bf4 --- /dev/null +++ b/roles/luther38.winlogbeat/meta/main.yml @@ -0,0 +1,60 @@ +galaxy_info: + author: your name + description: your description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: license (GPLv2, CC-BY, etc) + + min_ansible_version: 2.4 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # Optionally specify the branch Galaxy will use when accessing the GitHub + # repo for this role. During role install, if no tags are available, + # Galaxy will use this branch. During import Galaxy will access files on + # this branch. If Travis integration is configured, only notifications for this + # branch will be accepted. Otherwise, in all cases, the repo's default branch + # (usually master) will be used. + #github_branch: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. \ No newline at end of file diff --git a/roles/luther38.winlogbeat/tasks/main.yml b/roles/luther38.winlogbeat/tasks/main.yml new file mode 100644 index 0000000..098aa89 --- /dev/null +++ b/roles/luther38.winlogbeat/tasks/main.yml @@ -0,0 +1,6 @@ +--- +# tasks file for luther38.winlogbeat + +- name: Install Metricbeat on Windows + when: ansible_os_family == 'Windows' + include: windows.yml diff --git a/roles/luther38.winlogbeat/tasks/windows.yml b/roles/luther38.winlogbeat/tasks/windows.yml new file mode 100644 index 0000000..e7ff0dd --- /dev/null +++ b/roles/luther38.winlogbeat/tasks/windows.yml @@ -0,0 +1,62 @@ +#https://artifacts.elastic.co/downloads/beats/winlogbeat/metricbeat-7.0.0-windows-x86_64.zip +# This will install winlogbeat on a windows host. +--- +- name: make tmp folder + win_file: + path: c:\tmp\ + state: directory + +- name: download winlogbeat + win_get_url: + url: 'https://artifacts.elastic.co/downloads/beats/winlogbeat/winlogbeat-{{ version }}-windows-x86_64.zip' + dest: 'C:\tmp\winlogbeat-{{ version }}.zip' + force: no + +- name: unzip winlogbeat + win_unzip: + src: c:\tmp\winlogbeat-{{ version }}.zip + dest: C:\tmp\winlogbeat-{{ version }}\ + creates: C:\tmp\winlogbeat-{{ version }}\ + +- name: Copy winlogbeat-{{ version }} folder + win_command: powershell.exe copy-item -Path 'c:\tmp\winlogbeat-{{ version }}\winlogbeat-{{ version }}-windows-x86_64\' -Filter * -Recurse -Destination 'C:\Program Files\Winlogbeat\' + args: + creates: C:\Program Files\Winlogbeat\ + +- name: Update tmplate + win_template: + src: winlogbeat.j2 + dest: C:\Program Files\Winlogbeat\winlogbeat.yml + +- name: Check if winlogbeat service is installed + register: service + win_service: + name: winlogbeat + +#- debug: var=service + +- name: Install service + when: service.exists == false + win_command: powershell.exe -ExecutionPolicy ByPass -File install-service-winlogbeat.ps1 + args: + chdir: C:\program files\winlogbeat\ + +- name: check status service + register: service + win_service: + name: winlogbeat + +#- debug: var=service + +- name: restart service + when: service.state == 'running' + win_service: + name: winlogbeat + state: restarted + +- name: start service + when: service.state == 'stopped' + win_service: + name: winlogbeat + state: started + diff --git a/playbook/linux/elastic/winlogbeat.j2 b/roles/luther38.winlogbeat/templates/winlogbeat.j2 similarity index 100% rename from playbook/linux/elastic/winlogbeat.j2 rename to roles/luther38.winlogbeat/templates/winlogbeat.j2 diff --git a/roles/luther38.winlogbeat/tests/inventory b/roles/luther38.winlogbeat/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/luther38.winlogbeat/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/luther38.winlogbeat/tests/test.yml b/roles/luther38.winlogbeat/tests/test.yml new file mode 100644 index 0000000..e52b43a --- /dev/null +++ b/roles/luther38.winlogbeat/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - luther38.winlogbeat \ No newline at end of file diff --git a/roles/luther38.winlogbeat/vars/main.yml b/roles/luther38.winlogbeat/vars/main.yml new file mode 100644 index 0000000..8b53290 --- /dev/null +++ b/roles/luther38.winlogbeat/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for luther38.winlogbeat \ No newline at end of file diff --git a/roles/win_localdircopy/README.md b/roles/win_localdircopy/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/win_localdircopy/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/win_localdircopy/defaults/main.yml b/roles/win_localdircopy/defaults/main.yml new file mode 100644 index 0000000..001f5ab --- /dev/null +++ b/roles/win_localdircopy/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for win_localdircopy \ No newline at end of file diff --git a/roles/win_localdircopy/handlers/main.yml b/roles/win_localdircopy/handlers/main.yml new file mode 100644 index 0000000..480b525 --- /dev/null +++ b/roles/win_localdircopy/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for win_localdircopy \ No newline at end of file diff --git a/roles/win_localdircopy/meta/main.yml b/roles/win_localdircopy/meta/main.yml new file mode 100644 index 0000000..5d50bf4 --- /dev/null +++ b/roles/win_localdircopy/meta/main.yml @@ -0,0 +1,60 @@ +galaxy_info: + author: your name + description: your description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: license (GPLv2, CC-BY, etc) + + min_ansible_version: 2.4 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # Optionally specify the branch Galaxy will use when accessing the GitHub + # repo for this role. During role install, if no tags are available, + # Galaxy will use this branch. During import Galaxy will access files on + # this branch. If Travis integration is configured, only notifications for this + # branch will be accepted. Otherwise, in all cases, the repo's default branch + # (usually master) will be used. + #github_branch: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. \ No newline at end of file diff --git a/roles/win_localdircopy/tasks/main.yml b/roles/win_localdircopy/tasks/main.yml new file mode 100644 index 0000000..4d66bd7 --- /dev/null +++ b/roles/win_localdircopy/tasks/main.yml @@ -0,0 +1,2 @@ +--- +# tasks file for win_localdircopy \ No newline at end of file diff --git a/roles/win_localdircopy/tests/inventory b/roles/win_localdircopy/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/win_localdircopy/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/win_localdircopy/tests/test.yml b/roles/win_localdircopy/tests/test.yml new file mode 100644 index 0000000..73c7e0c --- /dev/null +++ b/roles/win_localdircopy/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - win_localdircopy \ No newline at end of file diff --git a/roles/win_localdircopy/vars/main.yml b/roles/win_localdircopy/vars/main.yml new file mode 100644 index 0000000..882aea6 --- /dev/null +++ b/roles/win_localdircopy/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for win_localdircopy \ No newline at end of file