Add nvim and configure options #39
@@ -7,7 +7,9 @@ ignore: |
|
|||||||
|
|
||||||
rules:
|
rules:
|
||||||
truthy:
|
truthy:
|
||||||
allowed-values: ['true', 'false']
|
allowed-values: ["true", "false"]
|
||||||
check-keys: false
|
check-keys: false
|
||||||
level: error
|
level: error
|
||||||
line-length: disable
|
line-length: disable
|
||||||
|
comments:
|
||||||
|
min-spaces-from-content: 1
|
||||||
|
@@ -24,12 +24,10 @@ pis:
|
|||||||
ansible_host: 192.168.90.3
|
ansible_host: 192.168.90.3
|
||||||
ansible_user: ansible
|
ansible_user: ansible
|
||||||
|
|
||||||
equinox-servers:
|
localhost:
|
||||||
hosts:
|
hosts:
|
||||||
apollo:
|
localhost-machine:
|
||||||
ansible_host: 23.97.157.206
|
ansible_connection: local
|
||||||
ansible_port: 2004
|
|
||||||
ansible_user: ansible
|
|
||||||
|
|
||||||
all:
|
all:
|
||||||
children:
|
children:
|
||||||
@@ -39,6 +37,4 @@ all:
|
|||||||
datacenter:
|
datacenter:
|
||||||
children:
|
children:
|
||||||
vpses:
|
vpses:
|
||||||
equinox:
|
localhost:
|
||||||
children:
|
|
||||||
equinox-servers:
|
|
||||||
|
@@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# defaults file for corepack
|
|
@@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# handlers file for corepack
|
|
@@ -1,58 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Check node version
|
|
||||||
shell: node --version
|
|
||||||
become: true
|
|
||||||
become_user: noahk
|
|
||||||
become_method: su
|
|
||||||
become_flags: '--login'
|
|
||||||
vars:
|
|
||||||
ansible_become_pass: "{{ noahk_password }}"
|
|
||||||
register: node_version
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Set node version if empty
|
|
||||||
set_fact:
|
|
||||||
node_version: 0.0.0
|
|
||||||
when: node_version.stdout is ""
|
|
||||||
|
|
||||||
- name: Enable corepack
|
|
||||||
shell: corepack enable
|
|
||||||
become: true
|
|
||||||
become_user: noahk
|
|
||||||
become_method: su
|
|
||||||
become_flags: '--login'
|
|
||||||
vars:
|
|
||||||
ansible_become_pass: "{{ noahk_password }}"
|
|
||||||
when: node_version.stdout is version('16.0.0', '<')
|
|
||||||
|
|
||||||
- name: Verify corepack
|
|
||||||
shell: corepack --version
|
|
||||||
become: true
|
|
||||||
become_user: noahk
|
|
||||||
become_method: su
|
|
||||||
become_flags: '--login'
|
|
||||||
vars:
|
|
||||||
ansible_become_pass: "{{ noahk_password }}"
|
|
||||||
register: corepack_version
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Enable pnpm latest version
|
|
||||||
shell: corepack prepare pnpm@latest --activate
|
|
||||||
become: true
|
|
||||||
become_user: noahk
|
|
||||||
become_method: su
|
|
||||||
become_flags: '--login'
|
|
||||||
vars:
|
|
||||||
ansible_become_pass: "{{ noahk_password }}"
|
|
||||||
when: node_version.stdout is version('16.0.0', '<')
|
|
||||||
|
|
||||||
- name: Test pnpm
|
|
||||||
shell: pnpm --version
|
|
||||||
become: true
|
|
||||||
become_user: noahk
|
|
||||||
become_method: su
|
|
||||||
become_flags: '--login'
|
|
||||||
vars:
|
|
||||||
ansible_become_pass: "{{ noahk_password }}"
|
|
||||||
register: pnpm_version
|
|
||||||
ignore_errors: true
|
|
@@ -1,2 +0,0 @@
|
|||||||
localhost
|
|
||||||
|
|
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: localhost
|
|
||||||
remote_user: root
|
|
||||||
roles:
|
|
||||||
- corepack
|
|
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
# vars file for nvm
|
|
||||||
noahk_password: 'Voorzitter17'
|
|
@@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# defaults file for docker
|
|
@@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# handlers file for docker
|
|
@@ -1,18 +0,0 @@
|
|||||||
# ===================================================================================================
|
|
||||||
# ? ABOUT
|
|
||||||
# @author : Noah Knegt
|
|
||||||
# @email : personal@noahknegt.com
|
|
||||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
|
||||||
# @createdOn : 31-03-2023
|
|
||||||
# @description : This will add selected users to the docker group.
|
|
||||||
# ===================================================================================================
|
|
||||||
|
|
||||||
---
|
|
||||||
- name: Add users to the docker group
|
|
||||||
become: true
|
|
||||||
user:
|
|
||||||
name: "{{ item }}"
|
|
||||||
groups: docker
|
|
||||||
append: true
|
|
||||||
with_items: "{{ docker_users }}"
|
|
||||||
when: docker_users is defined
|
|
@@ -1,24 +0,0 @@
|
|||||||
# ===================================================================================================
|
|
||||||
# ? ABOUT
|
|
||||||
# @author : Noah Knegt
|
|
||||||
# @email : personal@noahknegt.com
|
|
||||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
|
||||||
# @createdOn : 06-04-2023
|
|
||||||
# @description : This will make sure that docker buildx is installed.
|
|
||||||
# ===================================================================================================
|
|
||||||
|
|
||||||
---
|
|
||||||
- name: Check for docker-buildx
|
|
||||||
shell: docker buildx version
|
|
||||||
register: docker_buildx
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Install docker-buildx
|
|
||||||
package:
|
|
||||||
name: docker-buildx
|
|
||||||
state: present
|
|
||||||
when: docker_buildx.stdout is not defined
|
|
||||||
|
|
||||||
- name: Alias docker-buildx
|
|
||||||
shell: docker buildx install
|
|
||||||
when: docker_buildx.stdout is not defined
|
|
@@ -1,29 +0,0 @@
|
|||||||
# ===================================================================================================
|
|
||||||
# ? ABOUT
|
|
||||||
# @author : Noah Knegt
|
|
||||||
# @email : personal@noahknegt.com
|
|
||||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
|
||||||
# @createdOn : 31-03-2023
|
|
||||||
# @description : This will check if docker is installed as the latest version.
|
|
||||||
# ===================================================================================================
|
|
||||||
|
|
||||||
---
|
|
||||||
- name: Check docker version
|
|
||||||
shell: docker --version
|
|
||||||
register: docker_version
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Install jq
|
|
||||||
become: true
|
|
||||||
package:
|
|
||||||
name: jq
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Check if latest version is stable
|
|
||||||
shell: "curl -s https://api.github.com/repos/docker/cli/tags | jq -r '.[0].name' | grep -E -o '[0-9]+\\.[0-9]+\\.[0-9]+\\-?'"
|
|
||||||
register: docker_latest_version
|
|
||||||
|
|
||||||
- name: Compare versions
|
|
||||||
set_fact:
|
|
||||||
docker_update: true
|
|
||||||
when: docker_version.stdout is not defined
|
|
@@ -1,14 +0,0 @@
|
|||||||
# ===================================================================================================
|
|
||||||
# ? ABOUT
|
|
||||||
# @author : Noah Knegt
|
|
||||||
# @email : personal@noahknegt.com
|
|
||||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
|
||||||
# @createdOn : 31-03-2023
|
|
||||||
# @description : This will cleanup the docker script from the machine.
|
|
||||||
# ===================================================================================================
|
|
||||||
|
|
||||||
---
|
|
||||||
- name: Cleanup docker script
|
|
||||||
file:
|
|
||||||
path: /tmp/get-docker.sh
|
|
||||||
state: absent
|
|
@@ -1,15 +0,0 @@
|
|||||||
# ===================================================================================================
|
|
||||||
# ? ABOUT
|
|
||||||
# @author : Noah Knegt
|
|
||||||
# @email : personal@noahknegt.com
|
|
||||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
|
||||||
# @createdOn : 31-03-2023
|
|
||||||
# @description : This will download the docker install script.
|
|
||||||
# ===================================================================================================
|
|
||||||
|
|
||||||
---
|
|
||||||
- name: Download the docker install script
|
|
||||||
get_url:
|
|
||||||
url: https://get.docker.com
|
|
||||||
dest: /tmp/get-docker.sh
|
|
||||||
mode: 0755
|
|
@@ -1,13 +0,0 @@
|
|||||||
# ===================================================================================================
|
|
||||||
# ? ABOUT
|
|
||||||
# @author : Noah Knegt
|
|
||||||
# @email : personal@noahknegt.com
|
|
||||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
|
||||||
# @createdOn : 31-03-2023
|
|
||||||
# @description : This will install the docker engine.
|
|
||||||
# ===================================================================================================
|
|
||||||
|
|
||||||
---
|
|
||||||
- name: Run the docker install script
|
|
||||||
shell: /tmp/get-docker.sh
|
|
||||||
when: docker_update is defined
|
|
@@ -1,25 +0,0 @@
|
|||||||
# ===================================================================================================
|
|
||||||
# ? ABOUT
|
|
||||||
# @author : Noah Knegt
|
|
||||||
# @email : personal@noahknegt.com
|
|
||||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
|
||||||
# @createdOn : 27-03-2023
|
|
||||||
# @description : This will make sure that docker is installed on the machine.
|
|
||||||
# ===================================================================================================
|
|
||||||
|
|
||||||
---
|
|
||||||
- include_tasks: check_version.yml
|
|
||||||
|
|
||||||
- include_tasks: download.yml
|
|
||||||
when: docker_update is defined
|
|
||||||
|
|
||||||
- include_tasks: install.yml
|
|
||||||
when: docker_update is defined
|
|
||||||
|
|
||||||
- include_tasks: addusers.yml
|
|
||||||
when: docker_update is defined
|
|
||||||
|
|
||||||
- include_tasks: cleanup.yml
|
|
||||||
when: docker_update is defined
|
|
||||||
|
|
||||||
- include_tasks: buildx.yml
|
|
@@ -1,2 +0,0 @@
|
|||||||
localhost
|
|
||||||
|
|
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: localhost
|
|
||||||
remote_user: root
|
|
||||||
roles:
|
|
||||||
- docker
|
|
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
# vars file for docker
|
|
||||||
docker_users:
|
|
||||||
- noahk
|
|
||||||
- root
|
|
@@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# defaults file for node
|
|
@@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# handlers file for node
|
|
@@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Check node version
|
|
||||||
shell: node --version
|
|
||||||
become: true
|
|
||||||
become_user: noahk
|
|
||||||
become_method: su
|
|
||||||
become_flags: '--login'
|
|
||||||
vars:
|
|
||||||
ansible_become_pass: "{{ noahk_password }}"
|
|
||||||
register: node_version
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Install node
|
|
||||||
shell: nvm install --lts
|
|
||||||
become: true
|
|
||||||
become_user: noahk
|
|
||||||
become_method: su
|
|
||||||
become_flags: '--login'
|
|
||||||
vars:
|
|
||||||
ansible_become_pass: "{{ noahk_password }}"
|
|
||||||
when: node_version.stdout is ""
|
|
@@ -1,2 +0,0 @@
|
|||||||
localhost
|
|
||||||
|
|
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: localhost
|
|
||||||
remote_user: root
|
|
||||||
roles:
|
|
||||||
- node
|
|
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
# vars file for nvm
|
|
||||||
noahk_password: 'Voorzitter17'
|
|
@@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# defaults file for nvm
|
|
@@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# handlers file for nvm
|
|
@@ -1,20 +0,0 @@
|
|||||||
# ===================================================================================================
|
|
||||||
# ? ABOUT
|
|
||||||
# @author : Noah Knegt
|
|
||||||
# @email : personal@noahknegt.com
|
|
||||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
|
||||||
# @createdOn : 06-04-2023
|
|
||||||
# @description : This will check if nvm is installed as the latest version.
|
|
||||||
# ===================================================================================================
|
|
||||||
|
|
||||||
---
|
|
||||||
- name: Check nvm version
|
|
||||||
shell: nvm --version
|
|
||||||
become: true
|
|
||||||
become_user: noahk
|
|
||||||
become_method: su
|
|
||||||
become_flags: '--login'
|
|
||||||
vars:
|
|
||||||
ansible_become_pass: "{{ noahk_password }}"
|
|
||||||
register: nvm_version
|
|
||||||
ignore_errors: true
|
|
@@ -1,22 +0,0 @@
|
|||||||
# ===================================================================================================
|
|
||||||
# ? ABOUT
|
|
||||||
# @author : Noah Knegt
|
|
||||||
# @email : personal@noahknegt.com
|
|
||||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
|
||||||
# @createdOn : 06-04-2023
|
|
||||||
# @description : This will cleanup the system.
|
|
||||||
# ===================================================================================================
|
|
||||||
|
|
||||||
---
|
|
||||||
- name: Cleanup
|
|
||||||
file:
|
|
||||||
path: "{{ item }}"
|
|
||||||
state: absent
|
|
||||||
with_items:
|
|
||||||
- /tmp/nvm-install.sh
|
|
||||||
- /tmp/nvm-install.log
|
|
||||||
- /tmp/nvm-install.out
|
|
||||||
- /tmp/nvm-install.err
|
|
||||||
- /tmp/nvm-install.debug
|
|
||||||
- /tmp/nvm-install.info
|
|
||||||
- /tmp/nvm-install.warn
|
|
@@ -1,16 +0,0 @@
|
|||||||
# ===================================================================================================
|
|
||||||
# ? ABOUT
|
|
||||||
# @author : Noah Knegt
|
|
||||||
# @email : personal@noahknegt.com
|
|
||||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
|
||||||
# @createdOn : 06-04-2023
|
|
||||||
# @description : This will download the nvm install script.
|
|
||||||
# ===================================================================================================
|
|
||||||
|
|
||||||
---
|
|
||||||
- name: Download nvm
|
|
||||||
get_url:
|
|
||||||
url: https://raw.githubusercontent.com/nvm-sh/nvm/{{ nvm_latest_version.stdout }}/install.sh
|
|
||||||
dest: /tmp/nvm-install.sh
|
|
||||||
mode: 0755
|
|
||||||
when: nvm_version.stdout != nvm_latest_version.stdout or nvm_version.stdout == ""
|
|
@@ -1,13 +0,0 @@
|
|||||||
# ===================================================================================================
|
|
||||||
# ? ABOUT
|
|
||||||
# @author : Noah Knegt
|
|
||||||
# @email : personal@noahknegt.com
|
|
||||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
|
||||||
# @createdOn : 06-04-2023
|
|
||||||
# @description : This will get the latest version of nvm.
|
|
||||||
# ===================================================================================================
|
|
||||||
|
|
||||||
---
|
|
||||||
- name: Get the latest nvm version
|
|
||||||
shell: curl -s https://api.github.com/repos/nvm-sh/nvm/releases/latest | grep tag_name | cut -d '"' -f 4
|
|
||||||
register: nvm_latest_version
|
|
@@ -1,19 +0,0 @@
|
|||||||
# ===================================================================================================
|
|
||||||
# ? ABOUT
|
|
||||||
# @author : Noah Knegt
|
|
||||||
# @email : personal@noahknegt.com
|
|
||||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
|
||||||
# @createdOn : 06-04-2023
|
|
||||||
# @description : This will install nvm as the latest version.
|
|
||||||
# ===================================================================================================
|
|
||||||
|
|
||||||
---
|
|
||||||
- name: Install nvm
|
|
||||||
shell: /tmp/nvm-install.sh
|
|
||||||
become: true
|
|
||||||
become_user: noahk
|
|
||||||
become_method: su
|
|
||||||
become_flags: '--login'
|
|
||||||
vars:
|
|
||||||
ansible_become_pass: "{{ noahk_password }}"
|
|
||||||
when: nvm_version.stdout != nvm_latest_version.stdout or nvm_version.stdout == ""
|
|
@@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
- import_tasks: check_installed.yml
|
|
||||||
- import_tasks: get_version.yml
|
|
||||||
|
|
||||||
- import_tasks: download.yml
|
|
||||||
|
|
||||||
- import_tasks: install.yml
|
|
||||||
|
|
||||||
- import_tasks: cleanup.yml
|
|
@@ -1,2 +0,0 @@
|
|||||||
localhost
|
|
||||||
|
|
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: localhost
|
|
||||||
remote_user: root
|
|
||||||
roles:
|
|
||||||
- nvm
|
|
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
# vars file for nvm
|
|
||||||
noahk_password: 'Voorzitter17'
|
|
@@ -8,11 +8,11 @@
|
|||||||
# ===================================================================================================
|
# ===================================================================================================
|
||||||
|
|
||||||
---
|
---
|
||||||
- name: apt_update
|
- name: Update apt
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
update_cache: true
|
update-cache: true
|
||||||
|
|
||||||
- name: restart_sshd
|
- name: Restart sshd
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: "{{ openssh_service }}"
|
name: "{{ openssh_service }}"
|
||||||
state: restarted
|
state: restarted
|
||||||
|
17
roles/setup/tasks/config/noahk.yml
Normal file
17
roles/setup/tasks/config/noahk.yml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
- name: Setup dotfiles repo
|
||||||
|
when: inventory_hostname in groups['localhost']
|
||||||
|
ansible.builtin.git:
|
||||||
|
repo: https://git.noahknegt.com/noah.knegt/dotfiles.git # noqa: latest
|
||||||
|
depth: 1
|
||||||
|
dest: /home/noahk/dotfiles
|
||||||
|
accept_hostkey: true
|
||||||
|
|
||||||
|
- name: Use stow to set up config data
|
||||||
|
when: inventory_hostname in groups['localhost']
|
||||||
|
become: true
|
||||||
|
become_user: noahk
|
||||||
|
become_method: ansible.builtin.su
|
||||||
|
ansible.builtin.command: cd /home/noahk/dotfiles && stow -t ~ .
|
||||||
|
register: stow_output
|
||||||
|
changed_when: stow_output.rc != 0
|
@@ -9,16 +9,36 @@
|
|||||||
# ===================================================================================================
|
# ===================================================================================================
|
||||||
|
|
||||||
---
|
---
|
||||||
- include_vars: "{{ ansible_distribution }}.yml"
|
- name: Include distribution variables
|
||||||
|
ansible.builtin.include_vars:
|
||||||
|
file: "{{ ansible_distribution }}.yml"
|
||||||
|
|
||||||
# Setup the ansible user
|
# Setup the ansible user
|
||||||
- include_tasks: users/ansible.yml
|
- name: Create ansible user
|
||||||
- include_tasks: users/noahk.yml
|
ansible.builtin.include_tasks:
|
||||||
|
file: users/ansible.yml
|
||||||
|
- name: Create usable user
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: users/noahk.yml
|
||||||
|
|
||||||
# Setup the sshd
|
# Setup the sshd
|
||||||
- include_tasks: system/openssh.yml
|
- name: Setup openssh
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: system/openssh.yml
|
||||||
|
|
||||||
# Setup the repositories for Debian based systems
|
# Setup the repositories for Debian based systems
|
||||||
- include_tasks: software/repositories.yml
|
- name: Setup Debian based repositories
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: software/repositories.yml
|
||||||
|
|
||||||
- include_tasks: software/acl.yml
|
- name: Install and configure UFW
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: software/ufw.yml
|
||||||
|
|
||||||
|
- name: Install stow
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: software/stow.yml
|
||||||
|
|
||||||
|
- name: Configure the usable user
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: config/noahk.yml
|
||||||
|
@@ -1,15 +0,0 @@
|
|||||||
# ===================================================================================================
|
|
||||||
# ? ABOUT
|
|
||||||
# @author : Noah Knegt
|
|
||||||
# @email : personal@noahknegt.com
|
|
||||||
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
|
||||||
# @createdOn : 01-06-2023
|
|
||||||
# @description :
|
|
||||||
# ===================================================================================================
|
|
||||||
|
|
||||||
---
|
|
||||||
- name: Install acl
|
|
||||||
package:
|
|
||||||
name:
|
|
||||||
- acl
|
|
||||||
state: latest
|
|
@@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
- name: Install aptitude and software-properties-common
|
- name: Install aptitude and software-properties-common
|
||||||
package:
|
ansible.builtin.package:
|
||||||
name:
|
name:
|
||||||
- aptitude
|
- aptitude
|
||||||
- software-properties-common
|
- software-properties-common
|
||||||
state: latest
|
state: present
|
||||||
when: ansible_distribution in ["Debian", "Pop!_OS", "Ubuntu"]
|
when: ansible_distribution in ["Debian", "Pop!_OS", "Ubuntu"]
|
||||||
|
6
roles/setup/tasks/software/stow.yml
Normal file
6
roles/setup/tasks/software/stow.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
- name: Install stow
|
||||||
|
when: inventory_hostname in groups['localhost']
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: stow
|
||||||
|
state: present
|
47
roles/setup/tasks/software/ufw.yml
Normal file
47
roles/setup/tasks/software/ufw.yml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# ===================================================================================================
|
||||||
|
# ? ABOUT
|
||||||
|
# @author : Noah Knegt
|
||||||
|
# @email : personal@noahknegt.com
|
||||||
|
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
|
||||||
|
# @createdOn : 01-06-2023
|
||||||
|
# @description :
|
||||||
|
# ===================================================================================================
|
||||||
|
|
||||||
|
---
|
||||||
|
- name: Install UFW
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: ufw
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: UFW deny all incoming traffic
|
||||||
|
community.general.ufw:
|
||||||
|
default: deny
|
||||||
|
direction: incoming
|
||||||
|
|
||||||
|
- name: UFW allow all outbound traffic
|
||||||
|
community.general.ufw:
|
||||||
|
default: allow
|
||||||
|
direction: outgoing
|
||||||
|
|
||||||
|
- name: Allow all access from RFC1918 networks to this host
|
||||||
|
community.general.ufw:
|
||||||
|
direction: incoming
|
||||||
|
rule: allow
|
||||||
|
src: "{{ item }}"
|
||||||
|
loop:
|
||||||
|
- 10.0.0.0/8
|
||||||
|
- 172.16.0.0/12
|
||||||
|
- 192.168.0.0/16
|
||||||
|
|
||||||
|
- name: UFW allow default ssh port
|
||||||
|
community.general.ufw:
|
||||||
|
direction: incoming
|
||||||
|
rule: limit
|
||||||
|
port: ssh
|
||||||
|
|
||||||
|
- name: UFW allow custom ssh port
|
||||||
|
when: setup_openssh_port is defined
|
||||||
|
community.general.ufw:
|
||||||
|
direction: incoming
|
||||||
|
rule: allow
|
||||||
|
port: "{{ setup_openssh_port }}"
|
@@ -9,20 +9,22 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
- name: Install or update openssh
|
- name: Install or update openssh
|
||||||
package:
|
ansible.builtin.package:
|
||||||
name: "{{ openssh_package }}"
|
name: "{{ setup_openssh_package }}"
|
||||||
state: latest
|
state: present
|
||||||
notify:
|
notify:
|
||||||
- restart_sshd
|
- restart_sshd
|
||||||
|
|
||||||
- name: enable ssh daemon
|
- name: Enable ssh daemon
|
||||||
service:
|
when: inventory_hostname in groups['datacenter']
|
||||||
|
ansible.builtin.service:
|
||||||
name: "{{ openssh_service }}"
|
name: "{{ openssh_service }}"
|
||||||
state: started
|
state: started
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
- name: configure sshd
|
- name: Configure sshd
|
||||||
template:
|
when: inventory_hostname in groups['datacenter']
|
||||||
|
ansible.builtin.template:
|
||||||
src: sshd_config.j2
|
src: sshd_config.j2
|
||||||
dest: /etc/ssh/sshd_config
|
dest: /etc/ssh/sshd_config
|
||||||
owner: root
|
owner: root
|
||||||
@@ -31,10 +33,24 @@
|
|||||||
notify:
|
notify:
|
||||||
- restart_sshd
|
- restart_sshd
|
||||||
|
|
||||||
- name: copy sshd banner
|
- name: Copy sshd banner
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: ssh_banner.net
|
src: ssh_banner.net
|
||||||
dest: /etc/issue.net
|
dest: /etc/issue.net
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
|
||||||
|
- name: Copy ssh public key
|
||||||
|
ansible.builtin.authorized_key:
|
||||||
|
user: ansible
|
||||||
|
key: "{{ item }}"
|
||||||
|
with_file:
|
||||||
|
- ansible/ansible.pub
|
||||||
|
|
||||||
|
- name: Copy ssh public key
|
||||||
|
ansible.builtin.authorized_key:
|
||||||
|
user: noahk
|
||||||
|
key: "{{ item }}"
|
||||||
|
with_file:
|
||||||
|
- noahk/noahk.pub
|
||||||
|
@@ -1,49 +1,30 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: Install zsh
|
- name: Install zsh
|
||||||
become: true
|
become: true
|
||||||
package:
|
ansible.builting.package:
|
||||||
name: zsh
|
name: zsh
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Install oh-my-zsh
|
- name: Install oh-my-zsh
|
||||||
become: true
|
become: true
|
||||||
become_user: noahk
|
become_user: noahk
|
||||||
shell: sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
ansible.builtin.command: sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
||||||
|
changed_when: true
|
||||||
|
|
||||||
- name: Install zsh-syntax-highlighting
|
- name: Install zsh-syntax-highlighting
|
||||||
become: true
|
become: true
|
||||||
become_user: noahk
|
ansible.builtin.package:
|
||||||
git:
|
name: zsh-syntax-highlighting
|
||||||
repo: https://github.com/zsh-users/zsh-syntax-highlighting.git
|
state: present
|
||||||
dest: /home/noahk/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
|
|
||||||
update: true
|
|
||||||
|
|
||||||
- name: Install zsh-autosuggestions
|
- name: Install zsh-autosuggestions
|
||||||
become: true
|
become: true
|
||||||
become_user: noahk
|
ansible.builtin.package:
|
||||||
git:
|
name: zsh-autosuggestions
|
||||||
repo: https://github.com/zsh-users/zsh-autosuggestions.git
|
state: present
|
||||||
dest: /home/noahk/.oh-my-zsh/custom/plugins/zsh-autosuggestions
|
|
||||||
update: true
|
|
||||||
|
|
||||||
- name: Install starship
|
- name: Install starship
|
||||||
become: true
|
become: true
|
||||||
become_user: noahk
|
become_user: noahk
|
||||||
shell: sh -c "$(curl -fsSL https://starship.rs/install.sh)"
|
ansible.builtin.command: sh -c "$(curl -fsSL https://starship.rs/install.sh)"
|
||||||
|
changed_when: true
|
||||||
- name: Configure ZSH
|
|
||||||
become: true
|
|
||||||
become_user: noahk
|
|
||||||
template:
|
|
||||||
src: zshrc.j2
|
|
||||||
dest: /home/noahk/.zshrc
|
|
||||||
owner: noahk
|
|
||||||
group: noahk
|
|
||||||
mode: 0644
|
|
||||||
|
|
||||||
- name: Install nushell
|
|
||||||
become: true
|
|
||||||
package:
|
|
||||||
name: nushell
|
|
||||||
state: present
|
|
||||||
|
@@ -9,12 +9,12 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
- name: Add ansible group
|
- name: Add ansible group
|
||||||
group:
|
ansible.builtin.group:
|
||||||
name: ansible
|
name: ansible
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Add new ansible user
|
- name: Add new ansible user
|
||||||
user:
|
ansible.builtin.user:
|
||||||
name: ansible
|
name: ansible
|
||||||
group: ansible
|
group: ansible
|
||||||
groups: ansible,{{ sudo_group }}
|
groups: ansible,{{ sudo_group }}
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
shell: /bin/bash
|
shell: /bin/bash
|
||||||
|
|
||||||
- name: Add ansible user to sudoers
|
- name: Add ansible user to sudoers
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: ansible/ansible_sudoers
|
src: ansible/ansible_sudoers
|
||||||
dest: /etc/sudoers.d/ansible
|
dest: /etc/sudoers.d/ansible
|
||||||
owner: root
|
owner: root
|
||||||
@@ -31,18 +31,9 @@
|
|||||||
mode: 0440
|
mode: 0440
|
||||||
|
|
||||||
- name: Create .ssh directory
|
- name: Create .ssh directory
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: /home/ansible/.ssh
|
path: /home/ansible/.ssh
|
||||||
state: directory
|
state: directory
|
||||||
owner: ansible
|
owner: ansible
|
||||||
group: ansible
|
group: ansible
|
||||||
mode: 0700
|
mode: 0700
|
||||||
with_items:
|
|
||||||
- dir: /home/ansible/.ssh
|
|
||||||
|
|
||||||
- name: Copy ssh public key
|
|
||||||
authorized_key:
|
|
||||||
user: ansible
|
|
||||||
key: "{{ item }}"
|
|
||||||
with_file:
|
|
||||||
- ansible/ansible.pub
|
|
||||||
|
@@ -9,21 +9,21 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
- name: Create the group
|
- name: Create the group
|
||||||
group:
|
ansible.builtin.group:
|
||||||
name: noahk
|
name: noahk
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Create the user
|
- name: Create the user
|
||||||
user:
|
ansible.builtin.user:
|
||||||
name: noahk
|
name: noahk
|
||||||
group: noahk
|
group: noahk
|
||||||
groups: noahk,{{ sudo_group }}
|
groups: noahk,{{ setup_sudo_group }}
|
||||||
password: "{{ noahk_password }}"
|
password: "{{ setup_noahk_password }}"
|
||||||
state: present
|
state: present
|
||||||
shell: /bin/bash
|
shell: /bin/bash
|
||||||
|
|
||||||
- name: Add user to sudoers
|
- name: Add user to sudoers
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: noahk/noahk_sudoers
|
src: noahk/noahk_sudoers
|
||||||
dest: /etc/sudoers.d/noahk
|
dest: /etc/sudoers.d/noahk
|
||||||
owner: root
|
owner: root
|
||||||
@@ -31,18 +31,9 @@
|
|||||||
mode: 0440
|
mode: 0440
|
||||||
|
|
||||||
- name: Create .ssh directory
|
- name: Create .ssh directory
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: /home/noahk/.ssh
|
path: /home/noahk/.ssh
|
||||||
state: directory
|
state: directory
|
||||||
owner: noahk
|
owner: noahk
|
||||||
group: noahk
|
group: noahk
|
||||||
mode: 0700
|
mode: 0700
|
||||||
with_items:
|
|
||||||
- dir: /home/noahk/.ssh
|
|
||||||
|
|
||||||
- name: Copy ssh public key
|
|
||||||
authorized_key:
|
|
||||||
user: noahk
|
|
||||||
key: "{{ item }}"
|
|
||||||
with_file:
|
|
||||||
- noahk/noahk.pub
|
|
||||||
|
@@ -1,147 +0,0 @@
|
|||||||
# If you come from bash you might have to change your $PATH.
|
|
||||||
# export PATH=$HOME/bin:/usr/local/bin:$PATH
|
|
||||||
|
|
||||||
# Path to your oh-my-zsh installation.
|
|
||||||
ZSH=/usr/share/oh-my-zsh/
|
|
||||||
|
|
||||||
# Set name of the theme to load --- if set to "random", it will
|
|
||||||
# load a random theme each time oh-my-zsh is loaded, in which case,
|
|
||||||
# to know which specific one was loaded, run: echo $RANDOM_THEME
|
|
||||||
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
|
|
||||||
ZSH_THEME="amuse"
|
|
||||||
|
|
||||||
# Set list of themes to pick from when loading at random
|
|
||||||
# Setting this variable when ZSH_THEME=random will cause zsh to load
|
|
||||||
# a theme from this variable instead of looking in $ZSH/themes/
|
|
||||||
# If set to an empty array, this variable will have no effect.
|
|
||||||
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
|
|
||||||
|
|
||||||
# Uncomment the following line to use case-sensitive completion.
|
|
||||||
# CASE_SENSITIVE="true"
|
|
||||||
|
|
||||||
# Uncomment the following line to use hyphen-insensitive completion.
|
|
||||||
# Case-sensitive completion must be off. _ and - will be interchangeable.
|
|
||||||
# HYPHEN_INSENSITIVE="true"
|
|
||||||
|
|
||||||
# Uncomment the following line to disable bi-weekly auto-update checks.
|
|
||||||
DISABLE_AUTO_UPDATE="true"
|
|
||||||
|
|
||||||
# Uncomment the following line to automatically update without prompting.
|
|
||||||
# DISABLE_UPDATE_PROMPT="true"
|
|
||||||
|
|
||||||
# Uncomment the following line to change how often to auto-update (in days).
|
|
||||||
# export UPDATE_ZSH_DAYS=13
|
|
||||||
|
|
||||||
# Uncomment the following line if pasting URLs and other text is messed up.
|
|
||||||
# DISABLE_MAGIC_FUNCTIONS="true"
|
|
||||||
|
|
||||||
# Uncomment the following line to disable colors in ls.
|
|
||||||
# DISABLE_LS_COLORS="true"
|
|
||||||
|
|
||||||
# Uncomment the following line to disable auto-setting terminal title.
|
|
||||||
# DISABLE_AUTO_TITLE="true"
|
|
||||||
|
|
||||||
# Uncomment the following line to enable command auto-correction.
|
|
||||||
ENABLE_CORRECTION="true"
|
|
||||||
|
|
||||||
# Uncomment the following line to display red dots whilst waiting for completion.
|
|
||||||
# COMPLETION_WAITING_DOTS="true"
|
|
||||||
|
|
||||||
# Uncomment the following line if you want to disable marking untracked files
|
|
||||||
# under VCS as dirty. This makes repository status check for large repositories
|
|
||||||
# much, much faster.
|
|
||||||
# DISABLE_UNTRACKED_FILES_DIRTY="true"
|
|
||||||
|
|
||||||
# Uncomment the following line if you want to change the command execution time
|
|
||||||
# stamp shown in the history command output.
|
|
||||||
# You can set one of the optional three formats:
|
|
||||||
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
|
|
||||||
# or set a custom format using the strftime function format specifications,
|
|
||||||
# see 'man strftime' for details.
|
|
||||||
# HIST_STAMPS="mm/dd/yyyy"
|
|
||||||
|
|
||||||
# Would you like to use another custom folder than $ZSH/custom?
|
|
||||||
# ZSH_CUSTOM=/path/to/new-custom-folder
|
|
||||||
|
|
||||||
# Which plugins would you like to load?
|
|
||||||
# Standard plugins can be found in $ZSH/plugins/
|
|
||||||
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
|
|
||||||
# Example format: plugins=(rails git textmate ruby lighthouse)
|
|
||||||
# Add wisely, as too many plugins slow down shell startup.
|
|
||||||
plugins=(
|
|
||||||
zsh-autosuggestions
|
|
||||||
zsh-syntax-highlighting
|
|
||||||
git
|
|
||||||
|
|
||||||
cp
|
|
||||||
docker
|
|
||||||
docker-compose
|
|
||||||
dotenv
|
|
||||||
extract
|
|
||||||
git-auto-fetch
|
|
||||||
gitignore
|
|
||||||
golang
|
|
||||||
helm
|
|
||||||
jsontools
|
|
||||||
kubectl
|
|
||||||
nvm
|
|
||||||
rust
|
|
||||||
rsync
|
|
||||||
sudo
|
|
||||||
systemd
|
|
||||||
themes
|
|
||||||
tmux
|
|
||||||
vscode
|
|
||||||
nmap
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# User configuration
|
|
||||||
|
|
||||||
# Set the XDG_CONFIG_HOME in this file
|
|
||||||
XDG_CONFIG_HOME=${XDG_CONFIG_HOME:=${HOME}/.config}
|
|
||||||
|
|
||||||
# Source the env variables from the XDG_CONFIG_HOME
|
|
||||||
source $XDG_CONFIG_HOME/zsh/.zshenv
|
|
||||||
|
|
||||||
# export MANPATH="/usr/local/man:$MANPATH"
|
|
||||||
|
|
||||||
# You may need to manually set your language environment
|
|
||||||
# export LANG=en_US.UTF-8
|
|
||||||
|
|
||||||
# Preferred editor for local and remote sessions
|
|
||||||
# if [[ -n $SSH_CONNECTION ]]; then
|
|
||||||
# export EDITOR='vim'
|
|
||||||
# else
|
|
||||||
# export EDITOR='mvim'
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# Compilation flags
|
|
||||||
# export ARCHFLAGS="-arch x86_64"
|
|
||||||
|
|
||||||
# Set personal aliases, overriding those provided by oh-my-zsh libs,
|
|
||||||
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
|
|
||||||
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
|
|
||||||
# For a full list of active aliases, run `alias`.
|
|
||||||
#
|
|
||||||
# Example aliases
|
|
||||||
# alias zshconfig="mate ~/.zshrc"
|
|
||||||
# alias ohmyzsh="mate ~/.oh-my-zsh"
|
|
||||||
|
|
||||||
# Custom aliases
|
|
||||||
alias zshrc="nvim ~/.zshrc && source ~/.zshrc"
|
|
||||||
source $XDG_CONFIG_HOME/zsh/.aliases
|
|
||||||
|
|
||||||
ZSH_CACHE_DIR=$HOME/.cache/oh-my-zsh
|
|
||||||
if [[ ! -d $ZSH_CACHE_DIR ]]; then
|
|
||||||
mkdir $ZSH_CACHE_DIR
|
|
||||||
fi
|
|
||||||
|
|
||||||
source $ZSH/oh-my-zsh.sh
|
|
||||||
|
|
||||||
# For sharship rs loading
|
|
||||||
eval "$(starship init zsh)"
|
|
||||||
|
|
||||||
# tabtab source for packages
|
|
||||||
# uninstall by removing these lines
|
|
||||||
[[ -f ~/.config/tabtab/zsh/__tabtab.zsh ]] && . ~/.config/tabtab/zsh/__tabtab.zsh || true
|
|
@@ -8,7 +8,7 @@
|
|||||||
# ===================================================================================================
|
# ===================================================================================================
|
||||||
|
|
||||||
---
|
---
|
||||||
sudo_group: wheel
|
setup_sudo_group: wheel
|
||||||
openssh_service: sshd
|
setup_openssh_service: sshd
|
||||||
openssh_package: openssh
|
setup_openssh_package: openssh
|
||||||
sftp_path: /usr/lib/ssh/sftp-server
|
setup_sftp_path: /usr/lib/ssh/sftp-server
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
# ===================================================================================================
|
# ===================================================================================================
|
||||||
|
|
||||||
---
|
---
|
||||||
sudo_group: sudo
|
setup_sudo_group: sudo
|
||||||
openssh_service: ssh
|
setup_openssh_service: ssh
|
||||||
openssh_package: openssh-server
|
setup_openssh_package: openssh-server
|
||||||
sftp_path: /usr/lib/openssh/sftp-server
|
setup_sftp_path: /usr/lib/openssh/sftp-server
|
||||||
|
@@ -8,8 +8,7 @@
|
|||||||
# ===================================================================================================
|
# ===================================================================================================
|
||||||
|
|
||||||
---
|
---
|
||||||
sudo_group: sudo
|
setup_sudo_group: sudo
|
||||||
openssh_service: ssh
|
setup_openssh_service: ssh
|
||||||
openssh_package: openssh-server
|
setup_openssh_package: openssh-server
|
||||||
sftp_path: /usr/lib/openssh/sftp-server
|
setup_sftp_path: /usr/lib/openssh/sftp-server
|
||||||
ssh_port: 4422
|
|
||||||
|
@@ -8,5 +8,5 @@
|
|||||||
# ===================================================================================================
|
# ===================================================================================================
|
||||||
|
|
||||||
---
|
---
|
||||||
ansible_password: '$6$8eLzx6DNI/aamHAp$ZJK3kpbXDaMDUxuCFzRbbYL78aqdDnRRd1zbQPO2ED.pQQdcuAEnwBI2Vf3a36j7I5ED4STx6TLQnB8RiY3Vw/'
|
setup_ansible_password: "$6$8eLzx6DNI/aamHAp$ZJK3kpbXDaMDUxuCFzRbbYL78aqdDnRRd1zbQPO2ED.pQQdcuAEnwBI2Vf3a36j7I5ED4STx6TLQnB8RiY3Vw/"
|
||||||
noahk_password: '$6$8eLzx6DNI/aamHAp$ZJK3kpbXDaMDUxuCFzRbbYL78aqdDnRRd1zbQPO2ED.pQQdcuAEnwBI2Vf3a36j7I5ED4STx6TLQnB8RiY3Vw/'
|
setup_noahk_password: "$6$8eLzx6DNI/aamHAp$ZJK3kpbXDaMDUxuCFzRbbYL78aqdDnRRd1zbQPO2ED.pQQdcuAEnwBI2Vf3a36j7I5ED4STx6TLQnB8RiY3Vw/"
|
||||||
|
22
site.yml
22
site.yml
@@ -8,33 +8,27 @@
|
|||||||
# ===================================================================================================
|
# ===================================================================================================
|
||||||
|
|
||||||
---
|
---
|
||||||
- hosts: datacenter
|
- name: Setup
|
||||||
|
hosts: all
|
||||||
remote_user: root
|
remote_user: root
|
||||||
roles:
|
roles:
|
||||||
- role: setup
|
- role: setup
|
||||||
when: setup is defined
|
when: setup is defined
|
||||||
|
|
||||||
- hosts: datacenter
|
|
||||||
remote_user: ansible
|
|
||||||
roles:
|
|
||||||
- role: docker
|
|
||||||
- role: nvm
|
|
||||||
- role: node
|
|
||||||
- role: corepack
|
|
||||||
|
|
||||||
# Clean up the system
|
# Clean up the system
|
||||||
- hosts: datacenter
|
- name: Cleanup
|
||||||
|
hosts: all
|
||||||
remote_user: ansible
|
remote_user: ansible
|
||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: cleanup package cache (debian and ubuntu)
|
- name: Cleanup package cache (debian and ubuntu)
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
autoclean: true
|
autoclean: true
|
||||||
changed_when: false
|
changed_when: false
|
||||||
when: ansible_os_family == "Debian"
|
when: ansible_os_family == "Debian"
|
||||||
|
|
||||||
- name: autoremove packages (debian and ubuntu)
|
- name: Autoremove packages (debian and ubuntu)
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
autoremove: true
|
autoremove: true
|
||||||
purge: true
|
purge: true
|
||||||
when: ansible_os_family == "Debian"
|
when: ansible_os_family == "Debian"
|
||||||
|
Reference in New Issue
Block a user