diff --git a/beszel_install.yaml b/beszel_install.yaml new file mode 100644 index 0000000..27cf8be --- /dev/null +++ b/beszel_install.yaml @@ -0,0 +1,11 @@ +--- +- hosts: debianhosts + tasks: + - name: Install linux beszel agent + command: curl -sL https://get.beszel.dev -o /tmp/install-agent.sh && chmod +x /tmp/install-agent.sh && /tmp/install-agent.sh -p 45876 -k "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEhA2xm3yiEqzi5dn8UerbbhZTkU538O1g1KF2d7LefT" + +- hosts: windowshosts + tasks: + tasks: + - name: Install linux beszel agent + command: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser; & iwr -useb https://get.beszel.dev -OutFile "$env:TEMP\install-agent.ps1"; & "$env:TEMP\install-agent.ps1" -Key "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEhA2xm3yiEqzi5dn8UerbbhZTkU538O1g1KF2d7LefT" -Port 45876 \ No newline at end of file diff --git a/samples/._files b/samples/._files new file mode 100644 index 0000000..17a00bf Binary files /dev/null and b/samples/._files differ diff --git a/samples/.gitkeep b/samples/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/samples/files/ansible.ini b/samples/files/ansible.ini new file mode 100644 index 0000000..2fad12a --- /dev/null +++ b/samples/files/ansible.ini @@ -0,0 +1 @@ +ansible ansible_host=192.168.128.92 ansible_port=22 ansible_user=wjones ansible_ssh_private_key_file=/home/wjones/.ssh/id_rsa diff --git a/samples/files/hosts.ini b/samples/files/hosts.ini new file mode 100644 index 0000000..7e86232 --- /dev/null +++ b/samples/files/hosts.ini @@ -0,0 +1,29 @@ +ansible ansible_host=192.168.128.92 ansible_port=22 ansible_user=wjones ansible_ssh_private_key_file=/Users/wjones/Projects/ansible/files/id_rsa + +[debian_hosts] +gitlab.wpjones.com +pgserver.wpjones.com +plexserve1.wpjones.com +dhcpdns.wpjones.com +QDrive.wpjones.com +homeassistant.wpjones.com +homebridge.wpjones.com +firefly.wpjones.com +dockermain.wpjones.com + +[pve_hosts] +pve.wpjones.com +pve2.wpjones.com +pve3.wpjones.com + +[windows_hosts] +streamfab.wpjones.com +workstation.wpjones.com +qbit.wpjones.com +blueiris.wpjones.com +codeproject-ai.wpjones.com + + +[hosts:children] +pve_hosts +debian_hosts \ No newline at end of file diff --git a/samples/files/hosts.yaml b/samples/files/hosts.yaml new file mode 100644 index 0000000..c2e01b1 --- /dev/null +++ b/samples/files/hosts.yaml @@ -0,0 +1,11 @@ +all: + hosts: + gitlab.wpjones.com: + children: + cluster: + db: + hosts: + gitlab.wpjones.com: + windows: + hosts: + streamfab.wpjones.com: \ No newline at end of file diff --git a/samples/files/id_rsa b/samples/files/id_rsa new file mode 100644 index 0000000..161a379 --- /dev/null +++ b/samples/files/id_rsa @@ -0,0 +1,39 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIG4wIBAAKCAYEA2zq1G4kcCydcw2dwc2GTrP+my0dU9Ord7QmIWvSkXa8geyuW +SR4IvH3BtJysoqgq1N+hqiI0PdVf4uvun18Jb2gyCi7KCtr0UvKFAYx/YfitlCe0 +NMK/NFzVMBjaxPMoo8EiGnY/b+oo+f7iGOuZFqblvk1zld8+iEgc61iKhzE4nKqE +AsyepbqhqaJCcD4WWuGvv/jppVtABJ8H1cakBZRk1hKW2zy14jweuqrgkGXQUOlS +UWAcqlSrxWc6sygE0M8TmYlI+mzpkNZpbPYnGzSlMsV7BTQF0FGHU/cUmr20CewN +n1z0IslgHr9WehdieLiDGFBxmTf87Mo4+bu2inBzoULyQvAoudIC6ARwZbB86iHS +wFaufNYjCjJExhQoEzjfhiWdKWqc0T9zhR51zr7j9PylABzXBnOrWm9+VuQOVhCK +2bu0OyukNGi5vrBwJr3FUtxztJfwWyA8emRJ3oELSfOGOFqtvap/hyZkWclvMeG8 +t5FuFFalXJ4hUBfnAgMBAAECggGACWozheu0+xulJbUnBKV/oJHYGWnGUcBWaIwc +wX85IdbYB8Ie8aPrDyE9dOK3nUKomDzEZhiS8sbbl9S3CjwcH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S8FIWLlU/p0sNIDQlaeaAz/tfir1MOgMK5npKboEeDLIIbY +DBlp17C2Ls0ipgT0Q14SivTe0UH0FOKdSAVz6n50shzKTcGq60WxKu5cIio1v3wd +eR/qjpZ0RrW0wxB+VEEyY1AqBYj5IO6EBVUYjaKchqECgcEAjC1Iu66aCGnQUVgF +9+QesDLomexXJeQeqOCCWqfw5FJHP7ToQ0F9D6qod5qSioQBj2gbxG2V8C1YE5En +C/b1b3tb1ViZRbzDpYwC0yAgdwBmthtvptzOsRljP8IBvecW/nGfZBQZ1cB6e1P/ +yXzvEzv9zKllUDv5vThQH9Hd0x/Gt4p7jylVgQhR0C7i81RH+e9NCk5GPL27e4F6 +sDGkkrm26xPMY5n52M87vCI8MYCIwjiMDrpEt0LLDBVr+Yn3AoHAVF2ONinoO3cg +aREapsjaaZT0wxIZWZt03CcZK4P3yc2euYkqk/7ydRXg05PzQbZn67UNF0/mxzkv +3PRXbZtbXlU3vBx3kh+MKzIPftlThMcCnlEAGbWULfPiVNnfoO0/mltPJCCYFXon ++fQutBdmVv8nB6ssBZLycumaweMPzrJGQ8TCUG4G8nPmM4S9Nh6cPL9tF+QQM8FO +KmWuhB274irhAbKDYaBwbyyhYRebszgnTIYGbHhpQqJhSieoIevj +-----END RSA PRIVATE KEY----- diff --git a/samples/files/vault-demo.yaml b/samples/files/vault-demo.yaml new file mode 100644 index 0000000..634b3f4 --- /dev/null +++ b/samples/files/vault-demo.yaml @@ -0,0 +1,13 @@ +- hosts: localhost + vars: + vault_token: hvs.H9fmVpHzMP9dDeMiI7dJIdeZ + vault_url: 'https://vault.wpjones.com' + db_password: "{{ lookup('hashi_vault', 'secret=secret/passwords/db:data token={{ vault_token }} url={{ vault_url }}') }}" + system_password: "{{ lookup('hashi_vault', 'secret=secret/passwords/system:data token={{ vault_token }} url={{ vault_url }}') }}" + tasks: + - name: Value for system_password + debug: + msg: "system_password: {{ system_password }}" + - name: Value for db_password + debug: + msg: "db_password: {{ db_password }}" diff --git a/samples/files/win_servers.yaml b/samples/files/win_servers.yaml new file mode 100644 index 0000000..a44b1ad --- /dev/null +++ b/samples/files/win_servers.yaml @@ -0,0 +1,34 @@ +all: + hosts: + blueiris: + ansible_host: 192.168.128.75 + ansible_user: wjones + ansible_password: jones4295 + ansible_port: 5986 + ansible_connection: winrm + ansible_winrm_scheme: https + ansible_winrm_server_cert_validation: ignore + qbit: + ansible_host: 192.168.128.129 + ansible_user: wjones + ansible_password: jones4295 + ansible_port: 5986 + ansible_connection: winrm + ansible_winrm_scheme: https + ansible_winrm_server_cert_validation: ignore + streamfab: + ansible_host: 192.168.128.242 + ansible_user: wjones + ansible_password: jones4295 + ansible_port: 5986 + ansible_connection: winrm + ansible_winrm_scheme: https + ansible_winrm_server_cert_validation: ignore + codeproject-ai: + ansible_host: 192.168.128.221 + ansible_user: wjones + ansible_password: jones4295 + ansible_port: 5986 + ansible_connection: winrm + ansible_winrm_scheme: https + ansible_winrm_server_cert_validation: ignore \ No newline at end of file diff --git a/samples/playbooks/cmd.yaml b/samples/playbooks/cmd.yaml new file mode 100644 index 0000000..b27e11b --- /dev/null +++ b/samples/playbooks/cmd.yaml @@ -0,0 +1,9 @@ +- hosts: ansible + remote_user: root + become: yes + tasks: + - name: Curl Dockermain + shell: + cmd: curl http://dockermain:800 + register: curl + - debug: var=curl.stdout_lines \ No newline at end of file diff --git a/samples/playbooks/handler.yaml b/samples/playbooks/handler.yaml new file mode 100644 index 0000000..aab1311 --- /dev/null +++ b/samples/playbooks/handler.yaml @@ -0,0 +1,39 @@ +- hosts: ansible + remote_user: root + become: yes + tasks: +# - name: Install Apache +# apt: +# name: apache2 +# state: present +# notify: +# - Restart Apache +# - name: Install nano +# apt: +# name: nano +# state: present +# notify: +# - Restart Apache +# - name: Install MySQL +# apt: +# name: mysql-server +# state: present +# notify: +# - Restart Apache + - name: Remove Apache + apt: + name: apache2* + state: absent + - name: Remove nano + apt: + name: nano + state: absent + - name: Remove MySQL + apt: + name: mysql* + state: absent +# handlers: +# - name: Restart Apache +# service: +# name: apache2 +# state: restarted diff --git a/samples/playbooks/multi.yaml b/samples/playbooks/multi.yaml new file mode 100644 index 0000000..e9535c1 --- /dev/null +++ b/samples/playbooks/multi.yaml @@ -0,0 +1,19 @@ +- hosts: ansible + remote_user: root + become: yes + vars: + packages: + - apache2 + - nano + - mysql-server + tasks: + - name: Install Software + apt: + name: "{{ item }}" + state: present + loop: "{{ packages }}" + - name: Remove Software + apt: + name: "{{ item }}" + state: absent + loop: "{{ packages }}" \ No newline at end of file diff --git a/samples/playbooks/playbook.yaml b/samples/playbooks/playbook.yaml new file mode 100644 index 0000000..2e551f5 --- /dev/null +++ b/samples/playbooks/playbook.yaml @@ -0,0 +1,12 @@ +- hosts: ansible + remote_user: root + become: yes + tasks: + - name: Install Apache + apt: + name: apache2 + state: present + - name: Remove Apache + apt: + name: apache2 + state: absent \ No newline at end of file diff --git a/samples/playbooks/roles.yaml b/samples/playbooks/roles.yaml new file mode 100644 index 0000000..e69de29 diff --git a/samples/playbooks/service.yaml b/samples/playbooks/service.yaml new file mode 100644 index 0000000..36eebd0 --- /dev/null +++ b/samples/playbooks/service.yaml @@ -0,0 +1,16 @@ +- hosts: ansible + remote_user: root + become: yes + tasks: + - name: Install Apache + apt: + name: apache2 + state: present + - name: Restart Apache + service: + name: apache2 + state: restarted + - name: Remove Apache + apt: + name: apache2 + state: absent \ No newline at end of file diff --git a/samples/playbooks/var_role.yaml b/samples/playbooks/var_role.yaml new file mode 100644 index 0000000..6f6375c --- /dev/null +++ b/samples/playbooks/var_role.yaml @@ -0,0 +1,3 @@ +- hosts: ansible + roles: + - vardemo \ No newline at end of file diff --git a/samples/playbooks/varfile_demo.yaml b/samples/playbooks/varfile_demo.yaml new file mode 100644 index 0000000..68b8bf1 --- /dev/null +++ b/samples/playbooks/varfile_demo.yaml @@ -0,0 +1,11 @@ +- hosts: ansible + vars_files: + - vars.yaml + tasks: + - name: Display 1st Value + debug: + msg: "{{ http_port }}" + - name: Display 2nd Value + debug: + msg: "{{ server_name }}" +# Can be used with the inline specification" \ No newline at end of file diff --git a/samples/playbooks/variables_arrays.yaml b/samples/playbooks/variables_arrays.yaml new file mode 100644 index 0000000..38f86a7 --- /dev/null +++ b/samples/playbooks/variables_arrays.yaml @@ -0,0 +1,10 @@ +- hosts: ansible + vars: + courses: + - ansible + - terraform + - docker + tasks: + - name: Display Value + debug: + msg: "{{ courses [1] }}" \ No newline at end of file diff --git a/samples/playbooks/variables_basic.yaml b/samples/playbooks/variables_basic.yaml new file mode 100644 index 0000000..180ed03 --- /dev/null +++ b/samples/playbooks/variables_basic.yaml @@ -0,0 +1,7 @@ +- hosts: ansible + vars: + basic_var: My First Variable + tasks: + - name: Display Value + debug: + msg: "{{ basic_var }}" \ No newline at end of file diff --git a/samples/playbooks/vars.yaml b/samples/playbooks/vars.yaml new file mode 100644 index 0000000..68cd7b0 --- /dev/null +++ b/samples/playbooks/vars.yaml @@ -0,0 +1,2 @@ +http_port: 80 +server_name: ansible \ No newline at end of file diff --git a/samples/playbooks/web_challenge.yaml b/samples/playbooks/web_challenge.yaml new file mode 100644 index 0000000..e820014 --- /dev/null +++ b/samples/playbooks/web_challenge.yaml @@ -0,0 +1,29 @@ +- hosts: ansible + remote_user: root + become: yes + tasks: + - name: update packages + apt: + name: '*' + state: latest + register: apt + - debug: var=apt.stdout_lines + - name: Install Apache + apt: + name: apache2 + state: present + register: apt + notify: + - Restart Apache + - debug: var=apt.stdout_lines + - name: Create index.html + shell: echo "Hello From The Ansible Challenge 2" > /var/www/html/index.html + args: + executable: /bin/bash + register: apt + - debug: var=apt.stdout_lines + handlers: + - name: Restart Apache + service: + name: apache2 + state: reloaded \ No newline at end of file