Dies ist eine alte Version des Dokuments!
$ ansible-vault edit inventories/production/group_vars/all/admins
- admins
linux_admins: - user : Michael Nausch name : django groups : wheel ids : 1000 shell : /bin/bash state : present pwd : $6$QYCbUeY2/EecXmL4$iA7Q.M457er0F0354573RoPyKcbbPMozx8uFYKMpZLJnz2JIoAlcMxi0o0b1zJywJLECw1fSB2OCdfzc9vOX1 key : ssh-ed25519 AAAAC3N1NTE5A0aTHP001zaC1lZDI1NTE5AAAAINPs/cN40aTu2HTGeHhV7IV1EngqT5 openpgp:0xDAED833F - user : Christoph Leichi name : rookie groups : wheel ids : 1001 shell : /bin/bash state : present pwd : $6$n9UE0JVV7T.nzFJOdSY1dHDEsbfY3$0SPNKmewfaQ0z5thaRMrrrI9Uig.nzFJOdSY1erIZbw5yzDqeCg4S2oXa8zn2jEf9KDfjg31 key : ssh-ed25519 AAAAC3NzaqK6Pb38bv0oM9fw0C1lZDI1NTE5AAAAIDo46Pb38bv0oM9fmgM6byylc0815 rookie@nausch.org - user : Oliver Gewinnbringer name : oliver groups : wheel ids : 1002 shell : /bin/bash state : absent pwd : $6$nJVSYV9J17.SY1v0oM9fow8Do46dHDEsbfY3$0SPNKmewfaQ0z5tsafZi3haRMrrrI9Uig.OdSY1e6dHDEsbfY3$rI51ewfaQ0z5th key : ssh-ed25519 AAAAK6Pb38bv0oM9fw8DoOdSY1er4b38bNzaqK6Pb38bv0oM9fw01erIZbw5yzDqeCC5 oliver@nausch.org
--- - name: "Sicherstellen dass die Gruppen für Admin-User existieren" ansible.builtin.group: gid: '{{ item.ids }}' name: '{{ item.name }}' state: present with_items: '{{ linux_admins }}' - name: "Sicherstellen dass die Admin-User existieren" ansible.builtin.user: append: true comment: '{{ item.user }}' create_home: true force: true state: '{{ item.state }}' group: '{{ item.name }}' groups: '{{ item.groups }}' name: '{{ item.name }}' password: '{{ item.pwd }}' shell: '{{ item.shell }}' uid: '{{ item.ids }}' remove: true with_items: "{{ linux_admins }}" - name: "Gruppe entfernen, sofern der User zum Löschen gekennzeichnet ist mit absent im Inventory/Vault" ansible.builtin.group: gid: '{{ item.ids }}' name: '{{ item.name }}' state: '{{ item.state }}' with_items: '{{ linux_admins }}' - name: "SSH-Client-Verzeichnis anlegen" ansible.builtin.file: path: /home/{{ item.name }}/.ssh state: directory owner: '{{ item.name }}' group: '{{ item.name }}' mode: '0700' when: ' item.state == "present"' with_items: '{{ linux_admins }}' - name: "SSH-Key des Admins hinterlegen" ansible.builtin.copy: dest: /home/{{ item.name }}/.ssh/authorized_keys content: | {{ item.key }} owner: '{{ item.name }}' group: '{{ item.name }}' mode: '0600' when: ' item.state == "present"' with_items: '{{ linux_admins }}' - name: "VIM Konfig ablegen" ansible.builtin.copy: src: files/vimrc dest: /home/{{ item.name }}/.vimrc owner: '{{ item.name }}' group: '{{ item.name }}' mode: '0640' when: ' item.state == "present"' with_items: '{{ linux_admins }}' - name: "bashrc Konfig ablegen" ansible.builtin.copy: src: files/bashrc dest: /home/{{ item.name }}/.bashrc owner: '{{ item.name }}' group: '{{ item.name }}' mode: '0640' when: ' item.state == "present"' with_items: '{{ linux_admins }}' - name: "bash_logout Konfig ablegen" ansible.builtin.copy: src: files/bash_logout dest: /home/{{ item.name }}/.bash_logout owner: '{{ item.name }}' group: '{{ item.name }}' mode: '0640' when: ' item.state == "present"' with_items: '{{ linux_admins }}' - name: "bash_profile Konfig ablegen" ansible.builtin.copy: src: files/bash_profile dest: /home/{{ item.name }}/.bash_profile owner: '{{ item.name }}' group: '{{ item.name }}' mode: '0640' when: ' item.state == "present"' with_items: '{{ linux_admins }}' - name: "SSH-Client-Verzeichnis entfernen, sofern der User zum Löschen gekennzeichnet ist mit absent im Inventory/Vault" ansible.builtin.file: path: /home/{{ item.name }}/.ssh state: absent when: ' item.state == "absent" ' with_items: '{{ linux_admins }}' ...