Compare commits

...
15 Commits
28 changed files with 129 additions and 122 deletions

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
---
- hosts:
- tmp.kevinnlsamuel.com
vars:
ansible_user: root
alt_ssh_port: 1023
name: setup server natsuco
roles:
- kevinnlsamuel.galaxy.sshd.disablepasswd
- kevinnlsamuel.galaxy.sshd.altport
tasks:
@@ -0,0 +1 @@
Port {{ alt_ssh_port }}
-3
View File
@@ -1,3 +0,0 @@
[defaults]
inventory = ./hosts.ini
vault_password_file = ./secrets-client
+29 -39
View File
@@ -5,10 +5,16 @@
connection: local connection: local
name: setup fedora workstation name: setup fedora workstation
module_defaults:
ansible.builtin.dnf:
install_weak_deps: false
tasks: tasks:
- name: remove fedora fluff - name: remove fedora fluff
become: true become: true
ansible.builtin.dnf: ansible.builtin.dnf:
state: absent
allowerasing: true allowerasing: true
autoremove: true autoremove: true
name: name:
@@ -19,13 +25,11 @@
- python3-botocore - python3-botocore
- firefox - firefox
- nodejs - nodejs
state: absent
- name: install core components - name: install core components
become: true become: true
ansible.builtin.dnf: ansible.builtin.dnf:
state: present state: present
install_weak_deps: false
name: name:
- git - git
- git-crypt - git-crypt
@@ -54,50 +58,30 @@
dest: /usr/local/bin/ dest: /usr/local/bin/
src: https://github.com/ericchiang/pup/releases/download/v0.4.0/pup_v0.4.0_linux_amd64.zip src: https://github.com/ericchiang/pup/releases/download/v0.4.0/pup_v0.4.0_linux_amd64.zip
- name: install google-chrome dnf repository - name: install dnf repos
become: true include_role:
copy: role: installdnfrepo
dest: /etc/yum.repos.d/google-chrome.repo loop:
content: | - id: googlechrome
[google-chrome] baseurl: https://dl.google.com/linux/chrome/rpm/stable/x86_64
name=google-chrome gpgkey: https://dl.google.com/linux/linux_signing_key.pub
baseurl=https://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl.google.com/linux/linux_signing_key.pub
- name: install tailscale dnf repository - id: wayscriber
become: true baseurl: https://wayscriber.com/rpm
copy: gpgkey: https://wayscriber.com/rpm/RPM-GPG-KEY-wayscriber.asc
dest: /etc/yum.repos.d/tailscale.repo
content: |
[wayscriber]
name=Wayscriber
baseurl=https://wayscriber.com/rpm
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://wayscriber.com/rpm/RPM-GPG-KEY-wayscriber.asc
- name: install tailscale dnf repository - id: tailscale
become: true baseurl: https://pkgs.tailscale.com/stable/fedora/$basearch
copy: gpgkey: https://pkgs.tailscale.com/stable/fedora/repo.gpg
dest: /etc/yum.repos.d/tailscale.repo
content: | - id: charmcli
[tailscale] baseurl: https://repo.charm.sh/yum/
name=Tailscale gpgkey: https://repo.charm.sh/yum/gpg.key
baseurl=https://pkgs.tailscale.com/stable/fedora/$basearch
enabled=1
type=rpm
repo_gpgcheck=1
gpgcheck=1
gpgkey=https://pkgs.tailscale.com/stable/fedora/repo.gpg
- name: install dnf packages - name: install dnf packages
become: true become: true
ansible.builtin.dnf: ansible.builtin.dnf:
state: present state: present
install_weak_deps: false
name: name:
- aria2 - aria2
- bat - bat
@@ -106,6 +90,7 @@
- btrfs-progs - btrfs-progs
- coreutils - coreutils
- moreutils - moreutils
- parallel
- fcitx5-gtk4 - fcitx5-gtk4
- file - file
- gh - gh
@@ -304,6 +289,11 @@
firewall-cmd --permanent --zone home --add-service=kdeconnect --add-service=mosh --add-service=ssh firewall-cmd --permanent --zone home --add-service=kdeconnect --add-service=mosh --add-service=ssh
firewall-cmd --reload firewall-cmd --reload
- import_role:
role: managegooglechrome
become: true
name: set chrome policies
- name: enabled tailscaled service - name: enabled tailscaled service
become: true become: true
ansible.builtin.service: ansible.builtin.service:
-38
View File
@@ -1,38 +0,0 @@
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).
@@ -1,3 +0,0 @@
#SPDX-License-Identifier: MIT-0
---
# defaults file for .
@@ -1,3 +0,0 @@
#SPDX-License-Identifier: MIT-0
---
# handlers file for .
-3
View File
@@ -1,3 +0,0 @@
#SPDX-License-Identifier: MIT-0
---
# tasks file for .
-3
View File
@@ -1,3 +0,0 @@
#SPDX-License-Identifier: MIT-0
localhost
-6
View File
@@ -1,6 +0,0 @@
#SPDX-License-Identifier: MIT-0
---
- hosts: localhost
remote_user: root
roles:
- .
-3
View File
@@ -1,3 +0,0 @@
#SPDX-License-Identifier: MIT-0
---
# vars file for .
+9 -9
View File
@@ -1,28 +1,28 @@
- ansible.builtin.include_role: - ansible.builtin.import_role:
role: ensureparentdir role: ensuredir
apply: become: true
vars: vars:
path: "{{ path }}" path: "{{ subvpath | dirname }}"
- name: check if btrfs subv exists - name: check if btrfs subv exists
register: btrfssubvexists register: btrfssubvexists
become: true become: true
failed_when: false failed_when: false
changed_when: false changed_when: false
ansible.builtin.shell: "btrfs subv list {{ path | mandatory | dirname }} | grep -qF {{ path | basename }}" ansible.builtin.shell: "btrfs subv list {{ subvpath | mandatory | dirname }} | grep -qF {{ subvpath | basename }}"
- block: - block:
- name: "create btrfs subv {{ path | mandatory }}" - name: "create btrfs subv {{ subvpath | mandatory }}"
when: btrfssubvexists.rc != 0 when: btrfssubvexists.rc != 0
become: true become: true
ansible.builtin.command: ansible.builtin.command:
cmd: "btrfs subv create {{ path }}" cmd: "btrfs subv create {{ subvpath }}"
- name: "set owner:group of subv {{ path }}" - name: "set owner:group of subv {{ subvpath }}"
when: btrfssubvexists.rc != 0 when: btrfssubvexists.rc != 0
become: true become: true
ansible.builtin.file: ansible.builtin.file:
state: touch state: touch
path: "{{ path | mandatory }}" path: "{{ subvpath | mandatory }}"
owner: "{{ owner | mandatory }}" owner: "{{ owner | mandatory }}"
group: "{{ group | default(owner) }}" group: "{{ group | default(owner) }}"
+1 -1
View File
@@ -14,5 +14,5 @@
role: createbtrfssubv role: createbtrfssubv
apply: apply:
vars: vars:
path: "/home/{{ item.name }}/.local/share/containers" subvpath: "/home/{{ item.name }}/.local/share/containers"
owner: "{{ item.name }}" owner: "{{ item.name }}"
File renamed without changes.
@@ -1,29 +1,28 @@
- name: check if parent dir exists - name: check if dir exists
register: stat_output register: stat_output
ansible.builtin.stat: ansible.builtin.stat:
path: "{{ path | dirname }}" path: "{{ path }}"
- name: create dir if not exists - name: create dir if not exists
when: not stat_output.stat.exists when: not stat_output.stat.exists
ansible.builtin.file: ansible.builtin.file:
path: "{{ path | dirname }}" path: "{{ path }}"
state: directory state: directory
- name: backup and create dir if not dir - name: backup and create dir if not dir
when: stat_output.stat.exists and not stat_output.stat.isdir when: stat_output.stat.exists and not stat_output.stat.isdir
block: block:
- name: "backup existing {{ path | dirname }}" - name: "backup existing {{ path }}"
no_log: true no_log: true
ansible.builtin.copy: ansible.builtin.copy:
src: "{{ path | dirname }}" src: "{{ path }}"
dest: "{{ path | dirname }}.old" dest: "{{ path }}.old"
- name: "delete existing {{ path | dirname }}" - name: "delete existing {{ path }}"
no_log: true no_log: true
ansible.builtin.file: ansible.builtin.file:
path: "{{ path | dirname }}" path: "{{ path }}"
state: absent state: absent
- name: "create {{ path | dirname }}" - name: "create {{ path }}"
no_log: true
ansible.builtin.file: ansible.builtin.file:
path: "{{ path | dirname }}" path: "{{ path }}"
state: directory state: directory
+6
View File
@@ -0,0 +1,6 @@
galaxy_info:
author: kevinnlsamuel
description: sayin hello
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
+8
View File
@@ -0,0 +1,8 @@
- name: "install {{ item.id | default( id ) | mandatory }} dnf repository"
become: true
ansible.builtin.template:
dest: "/etc/yum.repos.d/{{ item.id | default( id ) | mandatory }}.repo"
src: dnfrepo.j2
owner: root
group: root
mode: 644
@@ -0,0 +1,7 @@
[{{ item.id | default( id ) | mandatory }}]
name={{ item.id | default( id ) | mandatory }}
baseurl={{ item.baseurl | default( baseurl ) | mandatory }}
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey={{ item.gpgkey | default( gpgkey ) | mandatory }}
+16
View File
@@ -0,0 +1,16 @@
- name: manage google chrome
block:
- ansible.builtin.file:
path: /etc/opt/chrome/policies/managed/
state: directory
owner: root
group: root
mode: '0755'
- ansible.builtin.copy:
src: disable-local-llm.json
dest: /etc/opt/chrome/policies/managed/disable-local-llm.json
owner: root
group: root
mode: '0644'
+5
View File
@@ -0,0 +1,5 @@
---
- name: restart sshd
service:
name: sshd
state: restarted
+1
View File
@@ -0,0 +1 @@
/home/kevins/Projects/galaxy/roles/sshd/_handlers
+16
View File
@@ -0,0 +1,16 @@
---
- name: change ssh port to {{ alt_ssh_port | mandatory }}
notify: restart sshd
template:
src: 00-altport.conf
dest: /etc/ssh/sshd_config.d/00-altport.conf
- name: install semanage
when: ansible_facts.selinux.status != 'disabled'
dnf:
state: present
name: policycoreutils-python-utils
- name: give sshd access to alt port on selinux
register: result_change_to_alt_port
ignore_errors: true
changed_when: "'already defined' not in result_change_to_alt_port.stdout"
command: semanage port -a -t ssh_port_t -p tcp {{ alt_ssh_port }}
@@ -0,0 +1 @@
Port {{ alt_ssh_port }}
@@ -0,0 +1 @@
PasswordAuthentication no
+1
View File
@@ -0,0 +1 @@
/home/kevins/Projects/galaxy/roles/sshd/_handlers
+5
View File
@@ -0,0 +1,5 @@
- name: disable password auth
notify: restart sshd
copy:
src: 00-nopasswd.conf
dest: /etc/ssh/sshd_config.d/00-nopasswd.conf