From c82c6eb42d14166087cf274caf32302a53814d29 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Fri, 3 May 2019 08:23:42 -0700 Subject: [PATCH 1/8] Updated cfg and added a ansible-pull script cfg now knows the default location to look for the inventory. Should have made that change long ago. Added a script to add all of my ansible-pull commands incase they need to be added back in to a new host. --- ansible.cfg | 2 +- scripts/ansiblepull.sh | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 scripts/ansiblepull.sh diff --git a/ansible.cfg b/ansible.cfg index 8b184d5..9301b00 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -11,7 +11,7 @@ # some basic default values... -inventory = ~/.ansible/hosts +inventory = ~/hosts library = /usr/share/my_modules/ module_utils = /usr/share/my_module_utils/ remote_tmp = ~/.ansible/tmp diff --git a/scripts/ansiblepull.sh b/scripts/ansiblepull.sh new file mode 100644 index 0000000..b3d2f2b --- /dev/null +++ b/scripts/ansiblepull.sh @@ -0,0 +1,11 @@ + +# 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 From d369f84902b93c14a0902836ed6ac6979e5e049a Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Fri, 3 May 2019 14:29:01 -0700 Subject: [PATCH 2/8] Create pull.yml This is a test file pulled from Ansible docs. --- playbook/pull.yml | 77 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 playbook/pull.yml diff --git a/playbook/pull.yml b/playbook/pull.yml new file mode 100644 index 0000000..1d95205 --- /dev/null +++ b/playbook/pull.yml @@ -0,0 +1,77 @@ +# ansible-pull setup +# +# on remote hosts, set up ansible to run periodically using the latest code +# from a particular checkout, in pull based fashion, inverting Ansible's +# usual push-based operating mode. +# +# This particular pull based mode is ideal for: +# +# (A) massive scale out +# (B) continual system remediation +# +# DO NOT RUN THIS AGAINST YOUR HOSTS WITHOUT CHANGING THE repo_url +# TO SOMETHING YOU HAVE PERSONALLY VERIFIED +# +# +--- + +- hosts: pull_mode_hosts + remote_user: root + + vars: + + # schedule is fed directly to cron + schedule: '*/15 * * * *' + + # User to run ansible-pull as from cron + cron_user: root + + # File that ansible will use for logs + logfile: /var/log/ansible-pull.log + + # Directory to where repository will be cloned + workdir: /var/lib/ansible/local + + # Repository to check out -- YOU MUST CHANGE THIS + # repo must contain a local.yml file at top level + #repo_url: git://github.com/sfromm/ansible-playbooks.git + repo_url: SUPPLY_YOUR_OWN_GIT_URL_HERE + + tasks: + + - name: Install ansible + apk: + name: ansible + state: installed + + - name: Create local directory to work from + file: + path: {{workdir}} + state: directory + owner: root + group: root + mode: 0751 + + - name: Copy ansible inventory file to client + copy: + src: /etc/ansible/hosts + dest: /etc/ansible/hosts + owner: root + group: root + mode: 0644 + + - name: Create crontab entry to clone/pull git repository + template: + src: templates/etc_cron.d_ansible-pull.j2 + dest: /etc/cron.d/ansible-pull + owner: root + group: root + mode: 0644 + + - name: Create logrotate entry for ansible-pull.log + template: + src: templates/etc_logrotate.d_ansible-pull.j2 + dest: /etc/logrotate.d/ansible-pull + owner: root + group: root + mode: 0644 From fad12ff06d615d8a5ee173609f5365b027ebc12d Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Mon, 6 May 2019 15:50:26 -0700 Subject: [PATCH 3/8] 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 From c094921e17eb064edc58dab30eed1addd58fa4c6 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Tue, 7 May 2019 15:21:33 -0700 Subject: [PATCH 4/8] renamed roles --- .gitignore | 7 ++++++- README.md | 6 ++++-- ansible.cfg | 2 +- playbook/linux/auto-securityupdates.yml | 1 + roles/{elasticsearch => luther38.elasticsearch}/README.md | 0 .../defaults/main.yml | 0 .../handlers/main.yml | 0 .../meta/main.yml | 0 .../tasks/install-repo.yml | 0 .../tasks/main.yml | 0 .../tasks/ubuntu.yml | 0 .../templates/elasticsearch.j2 | 0 .../tests/inventory | 0 .../tests/test.yml | 0 .../vars/main.yml | 0 roles/{kibana => luther38.kibana}/README.md | 0 roles/{kibana => luther38.kibana}/defaults/main.yml | 0 roles/{kibana => luther38.kibana}/handlers/main.yml | 0 roles/{kibana => luther38.kibana}/meta/main.yml | 0 roles/{kibana => luther38.kibana}/tasks/install-repo.yml | 0 roles/{kibana => luther38.kibana}/tasks/main.yml | 0 roles/{kibana => luther38.kibana}/tasks/ubuntu.yml | 0 roles/{kibana => luther38.kibana}/templates/kibana.j2 | 0 roles/{kibana => luther38.kibana}/tests/inventory | 0 roles/{kibana => luther38.kibana}/tests/test.yml | 0 roles/{kibana => luther38.kibana}/vars/main.yml | 0 26 files changed, 12 insertions(+), 4 deletions(-) rename roles/{elasticsearch => luther38.elasticsearch}/README.md (100%) rename roles/{elasticsearch => luther38.elasticsearch}/defaults/main.yml (100%) rename roles/{elasticsearch => luther38.elasticsearch}/handlers/main.yml (100%) rename roles/{elasticsearch => luther38.elasticsearch}/meta/main.yml (100%) rename roles/{elasticsearch => luther38.elasticsearch}/tasks/install-repo.yml (100%) rename roles/{elasticsearch => luther38.elasticsearch}/tasks/main.yml (100%) rename roles/{elasticsearch => luther38.elasticsearch}/tasks/ubuntu.yml (100%) rename roles/{elasticsearch => luther38.elasticsearch}/templates/elasticsearch.j2 (100%) rename roles/{elasticsearch => luther38.elasticsearch}/tests/inventory (100%) rename roles/{elasticsearch => luther38.elasticsearch}/tests/test.yml (100%) rename roles/{elasticsearch => luther38.elasticsearch}/vars/main.yml (100%) rename roles/{kibana => luther38.kibana}/README.md (100%) rename roles/{kibana => luther38.kibana}/defaults/main.yml (100%) rename roles/{kibana => luther38.kibana}/handlers/main.yml (100%) rename roles/{kibana => luther38.kibana}/meta/main.yml (100%) rename roles/{kibana => luther38.kibana}/tasks/install-repo.yml (100%) rename roles/{kibana => luther38.kibana}/tasks/main.yml (100%) rename roles/{kibana => luther38.kibana}/tasks/ubuntu.yml (100%) rename roles/{kibana => luther38.kibana}/templates/kibana.j2 (100%) rename roles/{kibana => luther38.kibana}/tests/inventory (100%) rename roles/{kibana => luther38.kibana}/tests/test.yml (100%) rename roles/{kibana => luther38.kibana}/vars/main.yml (100%) diff --git a/.gitignore b/.gitignore index 899db53..769761f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,12 @@ +# Ansible Files *.retry - *.swp + +# OSX files .DS_Store + + +# Ansible Inventory hosts win_hosts diff --git a/README.md b/README.md index 0b5b9ca..d07295a 100644 --- a/README.md +++ b/README.md @@ -25,11 +25,13 @@ powershell.exe -ExecutionPolicy ByPass -File $file ## Configuration -I have a basic configuration file in place at the root of this folder for anisble to find. +I have a basic configuration file in place at the root of this folder for anisble to find. If you work out of this directory the configuration file will take effect that is loaded. ## Inventory -I have a template file in place that should only be used as a refrence. Make a copy of that file and name it hosts then update that file. +I have a template file in place that should only be used as a reference. Make a copy of that file and name it hosts then update that file. + +The configuration file that is active is looking for a directory that contains all of the inventory files. This way all files can be parted out rather then one big file. ### Testing Linux devices diff --git a/ansible.cfg b/ansible.cfg index 9301b00..64e8afc 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -11,7 +11,7 @@ # some basic default values... -inventory = ~/hosts +inventory = ~/hosts/ library = /usr/share/my_modules/ module_utils = /usr/share/my_module_utils/ remote_tmp = ~/.ansible/tmp diff --git a/playbook/linux/auto-securityupdates.yml b/playbook/linux/auto-securityupdates.yml index 3a13640..122e948 100644 --- a/playbook/linux/auto-securityupdates.yml +++ b/playbook/linux/auto-securityupdates.yml @@ -5,6 +5,7 @@ hosts: linux tasks: + # https://galaxy.ansible.com/jnv/unattended-upgrades - name: unattended-upgrades become: true include_role: diff --git a/roles/elasticsearch/README.md b/roles/luther38.elasticsearch/README.md similarity index 100% rename from roles/elasticsearch/README.md rename to roles/luther38.elasticsearch/README.md diff --git a/roles/elasticsearch/defaults/main.yml b/roles/luther38.elasticsearch/defaults/main.yml similarity index 100% rename from roles/elasticsearch/defaults/main.yml rename to roles/luther38.elasticsearch/defaults/main.yml diff --git a/roles/elasticsearch/handlers/main.yml b/roles/luther38.elasticsearch/handlers/main.yml similarity index 100% rename from roles/elasticsearch/handlers/main.yml rename to roles/luther38.elasticsearch/handlers/main.yml diff --git a/roles/elasticsearch/meta/main.yml b/roles/luther38.elasticsearch/meta/main.yml similarity index 100% rename from roles/elasticsearch/meta/main.yml rename to roles/luther38.elasticsearch/meta/main.yml diff --git a/roles/elasticsearch/tasks/install-repo.yml b/roles/luther38.elasticsearch/tasks/install-repo.yml similarity index 100% rename from roles/elasticsearch/tasks/install-repo.yml rename to roles/luther38.elasticsearch/tasks/install-repo.yml diff --git a/roles/elasticsearch/tasks/main.yml b/roles/luther38.elasticsearch/tasks/main.yml similarity index 100% rename from roles/elasticsearch/tasks/main.yml rename to roles/luther38.elasticsearch/tasks/main.yml diff --git a/roles/elasticsearch/tasks/ubuntu.yml b/roles/luther38.elasticsearch/tasks/ubuntu.yml similarity index 100% rename from roles/elasticsearch/tasks/ubuntu.yml rename to roles/luther38.elasticsearch/tasks/ubuntu.yml diff --git a/roles/elasticsearch/templates/elasticsearch.j2 b/roles/luther38.elasticsearch/templates/elasticsearch.j2 similarity index 100% rename from roles/elasticsearch/templates/elasticsearch.j2 rename to roles/luther38.elasticsearch/templates/elasticsearch.j2 diff --git a/roles/elasticsearch/tests/inventory b/roles/luther38.elasticsearch/tests/inventory similarity index 100% rename from roles/elasticsearch/tests/inventory rename to roles/luther38.elasticsearch/tests/inventory diff --git a/roles/elasticsearch/tests/test.yml b/roles/luther38.elasticsearch/tests/test.yml similarity index 100% rename from roles/elasticsearch/tests/test.yml rename to roles/luther38.elasticsearch/tests/test.yml diff --git a/roles/elasticsearch/vars/main.yml b/roles/luther38.elasticsearch/vars/main.yml similarity index 100% rename from roles/elasticsearch/vars/main.yml rename to roles/luther38.elasticsearch/vars/main.yml diff --git a/roles/kibana/README.md b/roles/luther38.kibana/README.md similarity index 100% rename from roles/kibana/README.md rename to roles/luther38.kibana/README.md diff --git a/roles/kibana/defaults/main.yml b/roles/luther38.kibana/defaults/main.yml similarity index 100% rename from roles/kibana/defaults/main.yml rename to roles/luther38.kibana/defaults/main.yml diff --git a/roles/kibana/handlers/main.yml b/roles/luther38.kibana/handlers/main.yml similarity index 100% rename from roles/kibana/handlers/main.yml rename to roles/luther38.kibana/handlers/main.yml diff --git a/roles/kibana/meta/main.yml b/roles/luther38.kibana/meta/main.yml similarity index 100% rename from roles/kibana/meta/main.yml rename to roles/luther38.kibana/meta/main.yml diff --git a/roles/kibana/tasks/install-repo.yml b/roles/luther38.kibana/tasks/install-repo.yml similarity index 100% rename from roles/kibana/tasks/install-repo.yml rename to roles/luther38.kibana/tasks/install-repo.yml diff --git a/roles/kibana/tasks/main.yml b/roles/luther38.kibana/tasks/main.yml similarity index 100% rename from roles/kibana/tasks/main.yml rename to roles/luther38.kibana/tasks/main.yml diff --git a/roles/kibana/tasks/ubuntu.yml b/roles/luther38.kibana/tasks/ubuntu.yml similarity index 100% rename from roles/kibana/tasks/ubuntu.yml rename to roles/luther38.kibana/tasks/ubuntu.yml diff --git a/roles/kibana/templates/kibana.j2 b/roles/luther38.kibana/templates/kibana.j2 similarity index 100% rename from roles/kibana/templates/kibana.j2 rename to roles/luther38.kibana/templates/kibana.j2 diff --git a/roles/kibana/tests/inventory b/roles/luther38.kibana/tests/inventory similarity index 100% rename from roles/kibana/tests/inventory rename to roles/luther38.kibana/tests/inventory diff --git a/roles/kibana/tests/test.yml b/roles/luther38.kibana/tests/test.yml similarity index 100% rename from roles/kibana/tests/test.yml rename to roles/luther38.kibana/tests/test.yml diff --git a/roles/kibana/vars/main.yml b/roles/luther38.kibana/vars/main.yml similarity index 100% rename from roles/kibana/vars/main.yml rename to roles/luther38.kibana/vars/main.yml From b227938ad9d091b468b35357ec3e79891dd7fc44 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Tue, 7 May 2019 15:33:25 -0700 Subject: [PATCH 5/8] Added .vagrant to ignore --- .gitignore | 3 +++ .vagrant/machines/default/virtualbox/action_set_name | 1 - .vagrant/machines/default/virtualbox/creator_uid | 1 - .vagrant/machines/default/virtualbox/id | 1 - .vagrant/machines/default/virtualbox/index_uuid | 1 - .vagrant/machines/default/virtualbox/vagrant_cwd | 1 - .vagrant/rgloader/loader.rb | 9 --------- 7 files changed, 3 insertions(+), 14 deletions(-) delete mode 100644 .vagrant/machines/default/virtualbox/action_set_name delete mode 100644 .vagrant/machines/default/virtualbox/creator_uid delete mode 100644 .vagrant/machines/default/virtualbox/id delete mode 100644 .vagrant/machines/default/virtualbox/index_uuid delete mode 100644 .vagrant/machines/default/virtualbox/vagrant_cwd delete mode 100644 .vagrant/rgloader/loader.rb diff --git a/.gitignore b/.gitignore index 769761f..ee384af 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ # Ansible Inventory hosts win_hosts + +# Vagrant +.vagrant diff --git a/.vagrant/machines/default/virtualbox/action_set_name b/.vagrant/machines/default/virtualbox/action_set_name deleted file mode 100644 index b0f69f9..0000000 --- a/.vagrant/machines/default/virtualbox/action_set_name +++ /dev/null @@ -1 +0,0 @@ -1556550033 \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/creator_uid b/.vagrant/machines/default/virtualbox/creator_uid deleted file mode 100644 index 7cebf7d..0000000 --- a/.vagrant/machines/default/virtualbox/creator_uid +++ /dev/null @@ -1 +0,0 @@ -1001 \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/id b/.vagrant/machines/default/virtualbox/id deleted file mode 100644 index 22b3ed4..0000000 --- a/.vagrant/machines/default/virtualbox/id +++ /dev/null @@ -1 +0,0 @@ -96b95408-ffc7-44c3-919f-402645785ccd \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/index_uuid b/.vagrant/machines/default/virtualbox/index_uuid deleted file mode 100644 index eab0594..0000000 --- a/.vagrant/machines/default/virtualbox/index_uuid +++ /dev/null @@ -1 +0,0 @@ -3d922cc5783b466ab28a7ae61cc46639 \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/vagrant_cwd b/.vagrant/machines/default/virtualbox/vagrant_cwd deleted file mode 100644 index cf368e8..0000000 --- a/.vagrant/machines/default/virtualbox/vagrant_cwd +++ /dev/null @@ -1 +0,0 @@ -/home/jamestombleson/Documents/github/ansible \ No newline at end of file diff --git a/.vagrant/rgloader/loader.rb b/.vagrant/rgloader/loader.rb deleted file mode 100644 index c3c05b0..0000000 --- a/.vagrant/rgloader/loader.rb +++ /dev/null @@ -1,9 +0,0 @@ -# This file loads the proper rgloader/loader.rb file that comes packaged -# with Vagrant so that encoded files can properly run with Vagrant. - -if ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"] - require File.expand_path( - "rgloader/loader", ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"]) -else - raise "Encoded files can't be read outside of the Vagrant installer." -end From 9a21fd3da70236ff6feba1271df3547392ae7bff Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Tue, 14 May 2019 07:46:35 -0700 Subject: [PATCH 6/8] changed the cfg to look for hosts.d for host entries --- .gitignore | 1 + ansible.cfg | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ee384af..9660fda 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ # Ansible Inventory hosts win_hosts +hosts.d # Vagrant .vagrant diff --git a/ansible.cfg b/ansible.cfg index 64e8afc..abce976 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -11,7 +11,7 @@ # some basic default values... -inventory = ~/hosts/ +inventory = ~/hosts.d/ library = /usr/share/my_modules/ module_utils = /usr/share/my_module_utils/ remote_tmp = ~/.ansible/tmp From a26ed9ca328446f8e83b69e1efb312cccf9c8363 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Tue, 14 May 2019 08:54:40 -0700 Subject: [PATCH 7/8] Adjusted cfg. Changed hosts on Winlogbeat. POC for Jenkins is working --- ansible.cfg | 2 +- .../linux/elastic/install-role-winlogbeat.yml | 2 +- playbook/linux/install-jenkins.yml | 24 ++++++++++++------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ansible.cfg b/ansible.cfg index abce976..890b065 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -11,7 +11,7 @@ # some basic default values... -inventory = ~/hosts.d/ +inventory = ./hosts.d/ library = /usr/share/my_modules/ module_utils = /usr/share/my_module_utils/ remote_tmp = ~/.ansible/tmp diff --git a/playbook/linux/elastic/install-role-winlogbeat.yml b/playbook/linux/elastic/install-role-winlogbeat.yml index ead71a4..ba943da 100644 --- a/playbook/linux/elastic/install-role-winlogbeat.yml +++ b/playbook/linux/elastic/install-role-winlogbeat.yml @@ -1,7 +1,7 @@ --- - name: Install WinLogBeat - hosts: elasticClients + hosts: windows tasks: - name: Install WinLogBeat diff --git a/playbook/linux/install-jenkins.yml b/playbook/linux/install-jenkins.yml index b9b5d06..41e81a4 100644 --- a/playbook/linux/install-jenkins.yml +++ b/playbook/linux/install-jenkins.yml @@ -8,14 +8,20 @@ - name: Install Java become: yes import_role: - name: geerlingguy.java + name: geerlingguy.java - # https://galaxy.ansible.com/geerlingguy/jenkins - - name: Install Jenkins - become: yes - import_role: - name: geerlingguy.jenkins - vars: - jenkins_package_state: latest - jenkins_http_port: 8080 + - name: Install Jenkins + become: yes + import_role: + name: geerlingguy.jenkins + vars: + jenkins_package_state: latest + jenkins_http_port: 8080 + + - name: UFW Allow Jenkins + become: yes + ufw: + rule: allow + port: 8080 + comment: Jenkins From 0597719a6c011d7e76a10d97749971d1e37c3107 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Tue, 14 May 2019 10:51:24 -0700 Subject: [PATCH 8/8] Starting to have Jenkins run jobs Time for a new branch --- jenkins/README.md | 4 ++++ jenkins/auto-securityupdates.yml | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 jenkins/README.md create mode 100644 jenkins/auto-securityupdates.yml diff --git a/jenkins/README.md b/jenkins/README.md new file mode 100644 index 0000000..11faea7 --- /dev/null +++ b/jenkins/README.md @@ -0,0 +1,4 @@ +# Jenkins + +This is a folder that contains playbooks that will executed with Jenkins when code is pushed to master. + diff --git a/jenkins/auto-securityupdates.yml b/jenkins/auto-securityupdates.yml new file mode 100644 index 0000000..122e948 --- /dev/null +++ b/jenkins/auto-securityupdates.yml @@ -0,0 +1,17 @@ + +--- + +- name: enable + hosts: linux + + tasks: + # https://galaxy.ansible.com/jnv/unattended-upgrades + - name: unattended-upgrades + become: true + include_role: + name: jnv.unattended-upgrades + vars: + #unattended_package_blacklist: [] + unattended_automatic_reboot: true + +