summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruvok cheetah2022-12-29 11:15:03 +0100
committeruvok cheetah2022-12-29 11:15:03 +0100
commit1c0951c3eba906c996e0aa8b59f5e04a4b1a1ce9 (patch)
tree7bab7438f5a68f8e35e9f6bb68873b741d43969b
Initial commit
-rw-r--r--.gitignore6
-rw-r--r--ansible.cfg3
-rwxr-xr-xedit-vault.sh2
-rw-r--r--hello_world.yml10
-rw-r--r--hosts.yml35
-rw-r--r--initial-deploy.yml19
-rw-r--r--root_ls_color.yml11
-rw-r--r--upgrade.yml20
8 files changed, 106 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..934f586
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+/hosts
+/passwd.yml
+*.bak
+*~
+*.swp
+
diff --git a/ansible.cfg b/ansible.cfg
new file mode 100644
index 0000000..0e28f45
--- /dev/null
+++ b/ansible.cfg
@@ -0,0 +1,3 @@
+[defaults]
+inventory = ./hosts.yml
+
diff --git a/edit-vault.sh b/edit-vault.sh
new file mode 100755
index 0000000..76c3925
--- /dev/null
+++ b/edit-vault.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+ansible-vault edit passwd.yml
diff --git a/hello_world.yml b/hello_world.yml
new file mode 100644
index 0000000..67b340d
--- /dev/null
+++ b/hello_world.yml
@@ -0,0 +1,10 @@
+# To run this, name this file hello_world.yml and run the following in the same directory
+# ansible-playbook hello_world.yml -i 'local,' --connection=local
+
+- name: hello world example
+ hosts: all
+ tasks:
+ - name: Create a directory
+ file:
+ path=hello_world
+ state=directory
diff --git a/hosts.yml b/hosts.yml
new file mode 100644
index 0000000..738c6c3
--- /dev/null
+++ b/hosts.yml
@@ -0,0 +1,35 @@
+all:
+ children:
+ internal:
+ hosts:
+ pihole.lan: {}
+ srv-aptcache.lan: {}
+ srv-caddy.lan: {}
+ srv-calibre2.lan: {}
+ srv-cups2.lan: {}
+ srv-dnsdot: {}
+ srv-proxmox.lan: {}
+ srv-samba.lan: {}
+ srv-unifi2.lan: {}
+ vars:
+ ansible_become_pass: "{{ mypass }}"
+ ansible_user: ansible
+ server:
+ hosts:
+ static.242.186.47.78.clients.your-server.de: {}
+ vars:
+ ansible_user: root
+ vms:
+ hosts:
+ pihole.lan: {}
+ srv-aptcache.lan: {}
+ srv-caddy.lan: {}
+ srv-calibre2.lan: {}
+ srv-cups2.lan: {}
+ srv-dnsdot: {}
+ srv-samba.lan: {}
+ srv-unifi2.lan: {}
+ vars:
+ ansible_become_pass: "{{ mypass }}"
+ ansible_user: ansible
+
diff --git a/initial-deploy.yml b/initial-deploy.yml
new file mode 100644
index 0000000..8fa7330
--- /dev/null
+++ b/initial-deploy.yml
@@ -0,0 +1,19 @@
+- name: Setup Ansible user and authorized keys
+ gather_facts: false
+ hosts: new
+ tasks:
+ - name: Install sudo package
+ package:
+ name: "sudo"
+ state: "present"
+ - name: setup ansible user
+ user:
+ name: "ansible"
+ groups: "sudo"
+ password: "{{ new | password_hash('sha512') }}"
+ - name: Setup Authorized keys
+ authorized_key:
+ user: "ansible"
+ state: present
+ key: "{{ lookup('file', '~/.ssh/ansible.pub') }}"
+
diff --git a/root_ls_color.yml b/root_ls_color.yml
new file mode 100644
index 0000000..c40232b
--- /dev/null
+++ b/root_ls_color.yml
@@ -0,0 +1,11 @@
+- name: Make sure colorful ls
+ hosts: internal
+ gather_facts: false
+ tasks:
+ - name: Add line
+ lineinfile:
+ path: ~/.bashrc
+ state: present
+ search_string: "alias ls='ls --color=auto'"
+ line: "alias ls='ls -F --color=auto'"
+
diff --git a/upgrade.yml b/upgrade.yml
new file mode 100644
index 0000000..cf20df6
--- /dev/null
+++ b/upgrade.yml
@@ -0,0 +1,20 @@
+- name: Upgrade packages
+ hosts: all
+ gather_facts: false
+ tasks:
+ - name: Update and upgrade
+ apt:
+ update_cache: true
+ upgrade: safe
+ register: result
+ - name: Dump debug result
+ debug:
+ var: result
+ - name: Check if reboot required
+ stat:
+ path: /var/run/reboot-required
+ register: reboot_required_file
+ - name: Reboot if required
+ reboot:
+ when: reboot_required_file.stat.exists == true
+