Browse Source

1. commit

Mich 1 month ago
commit
b97b797b44

+ 1 - 0
.envrc

@@ -0,0 +1 @@
+export ANSIBLE_CONFIG=$(expand_path ansible.cfg)

+ 13 - 0
ans.txt

@@ -0,0 +1,13 @@
+insgesamt 76
+drwxr-xr-x 7 m-an m-an  4096  6. Sep 23:06 .
+drwxr-xr-x 5 m-an m-an  4096  5. Sep 10:24 ..
+-rw-r--r-- 1 m-an m-an   204  5. Sep 10:49 ansible.cfg
+-rw-r--r-- 1 m-an m-an 39584  3. Sep 11:20 ansible.cfg.01
+-rw-r--r-- 1 m-an m-an     0  6. Sep 23:08 ans.txt
+drwxr-xr-x 2 m-an m-an  4096  3. Sep 11:13 bin
+drwxr-xr-x 3 m-an m-an  4096  3. Sep 11:13 include
+drwxr-xr-x 2 m-an m-an  4096  5. Sep 13:00 inventory
+drwxr-xr-x 3 m-an m-an  4096  3. Sep 11:13 lib
+lrwxrwxrwx 1 m-an m-an     3  3. Sep 11:13 lib64 -> lib
+drwxr-xr-x 2 m-an m-an  4096  5. Sep 13:00 playbooks
+-rw-r--r-- 1 m-an m-an   164  3. Sep 11:13 pyvenv.cfg

+ 15 - 0
ansible.cfg

@@ -0,0 +1,15 @@
+[defaults]
+inventory=inventory/
+#inventory=inventory/hosts.yaml
+#vault_password_file=.vault-password
+playbook_dir=./playbooks/
+log_path=/tmp/ansible_ffhome.log
+
+stdout_callback=yaml
+display_args_to_stdout=True
+
+[privilege_escalation]
+become=True
+
+[ssh_connection]
+pipelining=True

File diff suppressed because it is too large
+ 683 - 0
ansible.cfg.01


+ 1 - 0
inventory/host_vars/gmuend/vars

@@ -0,0 +1 @@
+gmuend_password: "{{ vault_gmuend_password }}"

+ 2 - 0
inventory/host_vars/gmuend2lap/vars

@@ -0,0 +1,2 @@
+---  
+gmuend2lap_password: "{{ vault_gmuend2lap_password }}"

+ 1 - 0
inventory/host_vars/gmuendlap/vars

@@ -0,0 +1 @@
+gmuendlap_password: "{{ vault_gmuendlap_password }}"

+ 36 - 0
inventory/hosts

@@ -0,0 +1,36 @@
+# This is the default ansible 'hosts' file.
+#
+# It should live in /etc/ansible/hosts
+#
+#   - Comments begin with the '#' character
+#   - Blank lines are ignored
+#   - Groups of hosts are delimited by [header] elements
+#   - You can enter hostnames or ip addresses
+#   - A hostname/ip can be a member of multiple groups
+---
+all:
+  ansible_port: 24
+  ansible_user: m-an
+  ansible_become: true
+
+apu:
+  hosts:
+    gmuend:
+      ansible_host: 192.168.2.60
+      ansible_become_password: "{{ gmuend_password }}"
+
+desktops:
+  hosts:
+    gmuendlap:
+      ansible_host: 192.168.2.61
+      ansible_become_pass: '{{ gmuendlap_password }}'
+
+    gmuend2lap:
+      ansible_host: 192.xxx
+      ansible_become_pass: '{{ gmuend2lap_pw }}'
+
+#  127.0.0.1:24
+#  gmuend.ffdo.net:24 ansible_user=m-an ansible_become=true 
+#  hoerde.ffdo.net:24 ansible_user=maselmann ansible_become=true ansible_become_method=su
+#  194.104.114.172:24 ansible_user=maselmann ansible_become=true ansible_become_method=sudo
+#	nordstadt.ffdo.net:24  hat kein python, garkeins!

+ 40 - 0
inventory/hosts.yaml

@@ -0,0 +1,40 @@
+# This is the default ansible 'hosts' file.
+#
+# It should live in /etc/ansible/hosts
+#
+#   - Comments begin with the '#' character
+#   - Blank lines are ignored
+#   - Groups of hosts are delimited by [header] elements
+#   - You can enter hostnames or ip addresses
+#   - A hostname/ip can be a member of multiple groups
+---
+all:
+  vars: 
+    ansible_port: 24
+    ansible_user: m-an
+    ansible_become: true
+
+apu:
+  hosts:
+    gmuend:
+      ansible_host: 192.168.2.60
+#      ansible_port: 24
+      ansible_become_password: "{{ gmuend_password }}"
+
+desktops:
+  hosts:
+    gmuendlap:
+      ansible_host: 192.168.2.61
+#      ansible_port: 24
+      ansible_become_pass: '{{ gmuendlap_password }}'
+
+    gmuend2lap:
+      ansible_host: 192.168.2.62
+      ansible_port: 22
+      ansible_become_pass: '{{ gmuend2lap_password }}'
+
+#  127.0.0.1:24
+#  gmuend.ffdo.net:24 ansible_user=m-an ansible_become=true 
+#  hoerde.ffdo.net:24 ansible_user=maselmann ansible_become=true ansible_become_method=su
+#  194.104.114.172:24 ansible_user=maselmann ansible_become=true ansible_become_method=sudo
+#	nordstadt.ffdo.net:24  hat kein python, garkeins!

+ 8 - 0
playbooks/hallo.yaml

@@ -0,0 +1,8 @@
+---
+- hosts:
+  - ffhome
+  
+  gather_facts: no
+
+  tasks:
+    - debug: msg="Hallo Ansible!"

+ 12 - 0
playbooks/playbook.yaml

@@ -0,0 +1,12 @@
+- name: My first play
+  hosts: myhosts
+  tasks:
+   - name: Ping my hosts
+     ansible.builtin.ping:
+
+   - name: Print message
+     ansible.builtin.debug:
+      msg: Hello world
+
+#   - name: Updaten
+#     ansible.builtin.apt:

+ 36 - 0
playbooks/update.yaml

@@ -0,0 +1,36 @@
+---
+# name: update.yaml
+- hosts: [apu,desktops]
+
+  tasks:
+    - name: Testausgabe
+      debug: msg="Hallo von {{ ansible_hostname }} Ansible managed!"
+
+    - name: df -h Aufruf
+      command: df -h /
+      changed_when: false
+      register: df_cmd
+
+    - debug:
+        msg: '{{df_cmd.stdout_lines}} {{ansible_distribution }}'
+
+    - name: Ping my hosts
+      ansible.builtin.ping:
+      changed_when: false
+
+    - name: apt update mit upgrade und autoremove
+      ansible.builtin.apt:
+        update_cache: yes
+        cache_valid_time: 3600
+        autoremove: yes
+        upgrade: yes
+      when:  ansible_os_family == "Debian"
+
+#     - stat:
+#          path: /var/run/needrestart
+#        register: needrestart_file
+
+#      - name: reboot falls erforderlich
+#        ansible.builtin.reboot:
+#        when:
+#          - needrestart_file.stat.exists == True 

+ 9 - 0
playbooks/update.yaml.01

@@ -0,0 +1,9 @@
+---
+all:
+  hosts:
+    gmuend.ffdo.net: {
+      ansible_user: m-an,
+      ansible_port: 24,
+      ansible_host: 192.168.2.60,
+    }
+...

+ 5 - 0
pyvenv.cfg

@@ -0,0 +1,5 @@
+home = /usr/bin
+include-system-site-packages = false
+version = 3.11.2
+executable = /usr/bin/python3.11
+command = /usr/bin/python3 -m venv /home/m-an/ansible/ffhome