From fad12ff06d615d8a5ee173609f5365b027ebc12d Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Mon, 6 May 2019 15:50:26 -0700 Subject: [PATCH] Did some cleanup Added heartbeat role moved scripts to LinuxHelpers repo Moved old config files to the roles for archive. --- .../linux/elastic/config-win-metricbeat.yml | 56 ----------------- ...filebeat.yml => install-role-filebeat.yml} | 0 ...icbeat.yml => install-role-metricbeat.yml} | 0 ...ogbeat.yml => install-role-winlogbeat.yml} | 0 roles/luther38.heartbeat/README.md | 38 ++++++++++++ .../archive}/config-heartbeat.yml | 0 roles/luther38.heartbeat/defaults/main.yml | 2 + roles/luther38.heartbeat/handlers/main.yml | 2 + roles/luther38.heartbeat/meta/main.yml | 60 +++++++++++++++++++ roles/luther38.heartbeat/tasks/main.yml | 2 + .../templates}/heartbeat.j2 | 0 roles/luther38.heartbeat/tests/inventory | 2 + roles/luther38.heartbeat/tests/test.yml | 5 ++ roles/luther38.heartbeat/vars/main.yml | 2 + .../archive}/config-metricbeat.yml | 0 .../archive}/config-win-heartbeat.yml | 0 .../archive/install-metricbeat.yml | 16 +++++ .../archive}/config-winlogbeat.yml | 0 scripts/ansiblepull.sh | 11 ---- scripts/installAnsible.sh | 39 ------------ scripts/installOpenSSH.sh | 38 ------------ scripts/installTerraform.sh | 29 --------- scripts/installVagrant.sh | 35 ----------- 23 files changed, 129 insertions(+), 208 deletions(-) delete mode 100644 playbook/linux/elastic/config-win-metricbeat.yml rename playbook/linux/elastic/{install-filebeat.yml => install-role-filebeat.yml} (100%) rename playbook/linux/elastic/{install-metricbeat.yml => install-role-metricbeat.yml} (100%) rename playbook/linux/elastic/{install-winlogbeat.yml => install-role-winlogbeat.yml} (100%) create mode 100644 roles/luther38.heartbeat/README.md rename {playbook/linux/elastic => roles/luther38.heartbeat/archive}/config-heartbeat.yml (100%) create mode 100644 roles/luther38.heartbeat/defaults/main.yml create mode 100644 roles/luther38.heartbeat/handlers/main.yml create mode 100644 roles/luther38.heartbeat/meta/main.yml create mode 100644 roles/luther38.heartbeat/tasks/main.yml rename {playbook/linux/elastic => roles/luther38.heartbeat/templates}/heartbeat.j2 (100%) create mode 100644 roles/luther38.heartbeat/tests/inventory create mode 100644 roles/luther38.heartbeat/tests/test.yml create mode 100644 roles/luther38.heartbeat/vars/main.yml rename {playbook/linux/elastic => roles/luther38.metricbeat/archive}/config-metricbeat.yml (100%) rename {playbook/linux/elastic => roles/luther38.metricbeat/archive}/config-win-heartbeat.yml (100%) create mode 100644 roles/luther38.metricbeat/archive/install-metricbeat.yml rename {playbook/linux/elastic => roles/luther38.winlogbeat/archive}/config-winlogbeat.yml (100%) delete mode 100644 scripts/ansiblepull.sh delete mode 100644 scripts/installAnsible.sh delete mode 100755 scripts/installOpenSSH.sh delete mode 100644 scripts/installTerraform.sh delete mode 100755 scripts/installVagrant.sh diff --git a/playbook/linux/elastic/config-win-metricbeat.yml b/playbook/linux/elastic/config-win-metricbeat.yml deleted file mode 100644 index 66328e0..0000000 --- a/playbook/linux/elastic/config-win-metricbeat.yml +++ /dev/null @@ -1,56 +0,0 @@ ---- -# This will install all the client parts needed for elastic to monitor client computers - -- name: download metricbeat - win_get_url: - url: '{{ url_metricbeat }}' - dest: 'C:\temp\metricbeat-{{ elastic_version }}.zip' - force: no - -- name: unzip heartbeat - win_unzip: - src: c:\temp\metricbeat-{{ elastic_version }}.zip - dest: C:\temp\metricbeat-{{ elastic_version }}\ - creates: C:\temp\metricbeat-{{ elastic_version }}\ - -- name: Copy metricbeat-{{ elastic_version }} folder - win_command: powershell.exe copy-item -Path 'c:\temp\metricbeat-{{ elastic_version }}\metricbeat-{{ elastic_version }}-windows-x86_64\' -Filter * -Recurse -Destination 'C:\Program Files\Metricbeat\' - args: - creates: C:\Program Files\Metricbeat\ - -- name: Update template - win_template: - src: metricbeat.j2 - dest: C:\Program Files\Metricbeat\metricbeat.yml - -- name: Check if metricbeat service is installed - register: service_metricbeat - win_service: - name: metricbeat - -#- debug: var=service_metricbeat - -- name: Install Metricbeat service - win_command: powershell.exe -ExecutionPolicy ByPass -File install-service-metricbeat.ps1 - args: - chdir: C:\program files\metricbeat\ - when: service_metricbeat.exists == false - -- name: check status of metricbeat service - register: service_metricbeat - win_service: - name: metricbeat - -#- debug: var=service_metricbeat - -- name: restart service - win_service: - name: metricbeat - state: restarted - when: service_metricbeat.state == 'started' - -- name: start service - win_service: - name: metricbeat - state: started - when: service_metricbeat.state == 'stopped' diff --git a/playbook/linux/elastic/install-filebeat.yml b/playbook/linux/elastic/install-role-filebeat.yml similarity index 100% rename from playbook/linux/elastic/install-filebeat.yml rename to playbook/linux/elastic/install-role-filebeat.yml diff --git a/playbook/linux/elastic/install-metricbeat.yml b/playbook/linux/elastic/install-role-metricbeat.yml similarity index 100% rename from playbook/linux/elastic/install-metricbeat.yml rename to playbook/linux/elastic/install-role-metricbeat.yml diff --git a/playbook/linux/elastic/install-winlogbeat.yml b/playbook/linux/elastic/install-role-winlogbeat.yml similarity index 100% rename from playbook/linux/elastic/install-winlogbeat.yml rename to playbook/linux/elastic/install-role-winlogbeat.yml diff --git a/roles/luther38.heartbeat/README.md b/roles/luther38.heartbeat/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/luther38.heartbeat/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/playbook/linux/elastic/config-heartbeat.yml b/roles/luther38.heartbeat/archive/config-heartbeat.yml similarity index 100% rename from playbook/linux/elastic/config-heartbeat.yml rename to roles/luther38.heartbeat/archive/config-heartbeat.yml diff --git a/roles/luther38.heartbeat/defaults/main.yml b/roles/luther38.heartbeat/defaults/main.yml new file mode 100644 index 0000000..fb97c0a --- /dev/null +++ b/roles/luther38.heartbeat/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for luther38.heartbeat \ No newline at end of file diff --git a/roles/luther38.heartbeat/handlers/main.yml b/roles/luther38.heartbeat/handlers/main.yml new file mode 100644 index 0000000..1737524 --- /dev/null +++ b/roles/luther38.heartbeat/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for luther38.heartbeat \ No newline at end of file diff --git a/roles/luther38.heartbeat/meta/main.yml b/roles/luther38.heartbeat/meta/main.yml new file mode 100644 index 0000000..5d50bf4 --- /dev/null +++ b/roles/luther38.heartbeat/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.heartbeat/tasks/main.yml b/roles/luther38.heartbeat/tasks/main.yml new file mode 100644 index 0000000..90f3b82 --- /dev/null +++ b/roles/luther38.heartbeat/tasks/main.yml @@ -0,0 +1,2 @@ +--- +# tasks file for luther38.heartbeat \ No newline at end of file diff --git a/playbook/linux/elastic/heartbeat.j2 b/roles/luther38.heartbeat/templates/heartbeat.j2 similarity index 100% rename from playbook/linux/elastic/heartbeat.j2 rename to roles/luther38.heartbeat/templates/heartbeat.j2 diff --git a/roles/luther38.heartbeat/tests/inventory b/roles/luther38.heartbeat/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/luther38.heartbeat/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/luther38.heartbeat/tests/test.yml b/roles/luther38.heartbeat/tests/test.yml new file mode 100644 index 0000000..9a3e298 --- /dev/null +++ b/roles/luther38.heartbeat/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - luther38.heartbeat \ No newline at end of file diff --git a/roles/luther38.heartbeat/vars/main.yml b/roles/luther38.heartbeat/vars/main.yml new file mode 100644 index 0000000..6c953ab --- /dev/null +++ b/roles/luther38.heartbeat/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for luther38.heartbeat \ No newline at end of file diff --git a/playbook/linux/elastic/config-metricbeat.yml b/roles/luther38.metricbeat/archive/config-metricbeat.yml similarity index 100% rename from playbook/linux/elastic/config-metricbeat.yml rename to roles/luther38.metricbeat/archive/config-metricbeat.yml diff --git a/playbook/linux/elastic/config-win-heartbeat.yml b/roles/luther38.metricbeat/archive/config-win-heartbeat.yml similarity index 100% rename from playbook/linux/elastic/config-win-heartbeat.yml rename to roles/luther38.metricbeat/archive/config-win-heartbeat.yml diff --git a/roles/luther38.metricbeat/archive/install-metricbeat.yml b/roles/luther38.metricbeat/archive/install-metricbeat.yml new file mode 100644 index 0000000..8643cd0 --- /dev/null +++ b/roles/luther38.metricbeat/archive/install-metricbeat.yml @@ -0,0 +1,16 @@ +--- + +- name: Install Metricbeat + hosts: elasticClients + + tasks: + - name: Install Metricbeat + become: true + include_role: + name: luther38.metricbeat + vars: + kibana_host: 172.20.0.142 + elasticsearch_hosts: '["172.20.0.142:9200"]' + systemd_enable_service: true + systemd_restart_service: true + diff --git a/playbook/linux/elastic/config-winlogbeat.yml b/roles/luther38.winlogbeat/archive/config-winlogbeat.yml similarity index 100% rename from playbook/linux/elastic/config-winlogbeat.yml rename to roles/luther38.winlogbeat/archive/config-winlogbeat.yml diff --git a/scripts/ansiblepull.sh b/scripts/ansiblepull.sh deleted file mode 100644 index b3d2f2b..0000000 --- a/scripts/ansiblepull.sh +++ /dev/null @@ -1,11 +0,0 @@ - -# Script file to enable all of my ansible-pull commands. -# Used for documentation and rebuilding if needed - -# Notes -# -o command will only run the playbook when changes take place. - -$REPO = 'https://github.com/luther38/ansible.git' - -# This pb will tell all linux hosts to configure auto install of security updates -ansible-pull -U REPO -o playbook/linux/auto-securityupdates.yml diff --git a/scripts/installAnsible.sh b/scripts/installAnsible.sh deleted file mode 100644 index a4696fd..0000000 --- a/scripts/installAnsible.sh +++ /dev/null @@ -1,39 +0,0 @@ - -# Shell script to install ansible and other requirements. -# Currently only supports darwin for now. -# Ubuntu installer will be soon - -# 1.1: Added sudo command and justed the layout - - -echo "OS: $OSTYPE" -if [[ "$OSTYPE" == "darwin"* ]]; then - - echo "[brew] Intalling Ansible" - brew install ansible - -elif [[ "$OSTYPE" == "linux-gnu" ]]; then - echo "[sudo] Install Ansible" - sudo apt update - sudo apt install software-properties-common - sudo apt-add-repository --yes --update ppa:ansible/ansible - sudo apt install ansible -else - echo "Running on a unsupported OS" - echo "No changes where made" - exit -fi - -echo "[pip] Installing WinRM module" -sudo pip install pywinrm - -echo "[pip] Installing Azure module" -sudo pip install 'ansible[azure]' - -echo "[pip] Installing Docker module" -sudo pip install docker - - -echo "Installing roles from galaxy.ansible.com" -echo "[galaxy] Nagios Core - Server Side " -ansible-galaxy install networklore.nagios diff --git a/scripts/installOpenSSH.sh b/scripts/installOpenSSH.sh deleted file mode 100755 index c85643d..0000000 --- a/scripts/installOpenSSH.sh +++ /dev/null @@ -1,38 +0,0 @@ -# This script will do the following -# 1. Install OpenSSH -# 2. Make a user named Ansible -# 3. Give account sudo -# 4. Confirm SSH is active and running -# If you want to change how SSH is configured you will need to update the config by hand. Currently not supported by this script. - -# Use of this script is without warranty. Use at your own risk. - -echo "Installing OpenSSH Server" -sudo apt-get update -sudo apt-get install openssh-server -y - -echo "Going to create user: ansible" -sudo adduser ansible - -echo "Giving ansible sudo permissions" -sudo usermod -aG sudo ansible - -sudo systemctl status ssh - -echo "Install is complete. Test ansible!" -echo "If you want to change the port, check this scripts config on how to" -echo "With the ansible device you will want to connect to this host to get the SSH key from it before testing." - -# Edit /etc/ssh/sshd_config -# Uncomment #Port 22 -# Change the port number -# Save and Close - - -# Change the port from commented to uncommented -# If it is already uncommented, this will do nothing. -#sed -i "/#PORT =.*/PORT = $port" ~/cfg - -# Change the port to what we want -#sed -i "s/PORT/= .*/= $port" ~/cfg - diff --git a/scripts/installTerraform.sh b/scripts/installTerraform.sh deleted file mode 100644 index 98ca892..0000000 --- a/scripts/installTerraform.sh +++ /dev/null @@ -1,29 +0,0 @@ - -# This will install Terraform on the device - -#1.0 Started to add Terraform to the project - -echo "OS: $OSTYPE" -if [[ "$OSTYPE" == "darin"* ]]; then - -# I use debian so sudo -elif [[ "$OSTYPE" == "linux-gnu" ]]; then - - # Download current release - wget https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_amd64.zip - - unzip terraform_0.11.13_linux_amd64.zip - - # Remove the zip - rm terraform_0.11.13_linux_amd64.zip - - # copy over to bin - sudo cp terraform /bin/terraform - - rm terraform - -else - echo "You are running on a OS that is not supported by this script at this time." - echo "No changes have been made." - exit -fi diff --git a/scripts/installVagrant.sh b/scripts/installVagrant.sh deleted file mode 100755 index 9d7c550..0000000 --- a/scripts/installVagrant.sh +++ /dev/null @@ -1,35 +0,0 @@ - -# This will install Vagrant on the device - -#1.0 Started to add Vagrant to the project - -echo "OS: $OSTYPE" -if [[ "$OSTYPE" == "darin"* ]]; then - -# I use debian so sudo -elif [[ "$OSTYPE" == "linux-gnu" ]]; then - - # Download current release - wget https://releases.hashicorp.com/vagrant/2.2.4/vagrant_2.2.4_linux_amd64.zip - - unzip vagrant_2.2.4_linux_amd64.zip - - # Remove the zip - rm vagrant_2.2.4_linux_amd64.zip - - # copy over to bin - sudo cp vagrant /usr/bin/vagrant - - rm vagrant - - echo "Installing VirtualBox 6" - wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - - wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add - - sudo add-apt-repository "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian cosmic contrib" - sudo apt update - sudo apt install virtualbox-6.0 -else - echo "You are running on a OS that is not supported by this script at this time." - echo "No changes have been made." - exit -fi