diff --git a/inventory b/inventory index 06fa261..74fca67 100644 --- a/inventory +++ b/inventory @@ -1,5 +1,49 @@ all: + vars: + users: + - logname: "alex" + viewname: "Alexander Dahl" + email: "alex@netz39.de" + ssh_pub: + - !unsafe > + ssh-rsa + AAAAB3NzaC1yc2EAAAADAQABAAABAQDVZPAE3XE8Ek1Ji4sCIHxLVx+bi2qpsTSsYhBqtYysnFn9AHJj14BR59D0Si05sfVkmL4OQoo7Q98oIxy33PgtqoUfgXk9dc7dlsye3t/gsAb25ABnqG/ZYe65nZLN7BzRM1/QZIbd6sSu6eXrNFCh0ikB5se4zgVkDO8t6h2dnz4FvTuIM2Bi/PnIJTqb8+uLQE1vS3A7tTx100ZKXxr81dlo2Y1JBP6WrS1W1IyFiG6wofl2XTY02ssyoENQyR89lLMJYKvm5xlhL/L69gtMsqIX9UBQFk8Rpq04ZIwN6b0K4R142GZvxdJNdQULgtI3gPkKgH7FDoFsRHNA6b/9 + adahl@ada + - !unsafe > + ssh-rsa + AAAAB3NzaC1yc2EAAAADAQABAAABAQDvczlb1+9d1BjuLk5ZcQt2Z0Dh61Vg91i47tM48CN2koJ4I/9vgN37l6mnr383zD8kQkXDGmCYpXOa48WocyyUuP3h75DCjANYcWOsohQfFu2F1ZOiiVCGduDntzS2nbZEF2W3nZNLQ6/dKKEeaSxu5RjKflkWakghkMt3H4KN20bxzYzHQMLhRYFEGHpskOqeaXKPkqqEP+u5kToINtmXwegCvQFnlx4fNrysFII79buBNlcLsO1X4ABucVMYT/OJnBpJEfEcNFUKrJZRGgM8aDbUpkV9LRY2lywvoKJhiRMc7x7kK0LWOTdPJri+SJhW6fEW4JKCRTSHVN8OS8S/ + alex@buffy + - !unsafe > + ssh-rsa + AAAAB3NzaC1yc2EAAAABIwAAAQEAsGvQ1COtwA4ERf+Z/IMxlw4RadCVKIQzB6v8n20dDM+bfBmTxk7NeSGbdB/vjvUV0Oq47KfDISDAlwhSv0aSpij3d7twPWrFz7eoFWAGO2mnz39btA1i9ygMyp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uc6z5Vbwh4CbBFSg19f8B9rUO2ITjgmEvkY + alex@lemmy + sudo: yes + docker: yes + - logname: "tux" + viewname: "Stefan Haun" + email: "tux@netz39.de" + ssh_pub: + - !unsafe > + ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvxbl9eiBojG2zKw2eSftwaMpA4XeONJpPK++WBUBJi+4RhvtN+8YX55cGsRlAA2pvW1a6hxjuR/NEA0+EAZ8ueNaOrMJjHvuUSzO76YF1gHlusAbhYvNl4EYZz/lkrFM4oaa/4/WirgUvSKnpPQx2YgX/AEkIwzk6nQLve+NmijkWdWzaww5snjbAEsgo+iEqeLPRfzbxX4Esp8bqFy3qD0SGgJM8iWlUaWCoQI1HhU4lVBtwdR6cJQ3QnmhUidRLOpIpX1sBRM8Cnwc5g2u3OpsaxPd77+5hXtxKjQUby/YLGmr6L2x1tWYqkV+GZA0Lh3fwM0BjDVT/Y/a+HUVh tux@netz39.de + sudo: yes + docker: yes + + hosts: + tau.netz39.de: + children: tau: hosts: - tau.netz39.de + tau.netz39.de: diff --git a/main.yml b/main.yml index 008a3ad..a4e6009 100644 --- a/main.yml +++ b/main.yml @@ -6,7 +6,6 @@ ansible_python_interpreter: /usr/bin/python3 server_admin: "admin@netz39.de" - admin_users: [tux, alex] ag_timezone: Europe/Berlin @@ -47,13 +46,12 @@ unattended_mail: 'root' - name: Setup users - include_tasks: tasks/users.yml + include_role: + name: users - name: Install Docker include_role: name: install-docker - vars: - docker_users: "{{ admin_users }}" - name: Setup Docker Environment include_tasks: tasks/docker_env.yml diff --git a/roles/install-docker/tasks/main.yml b/roles/install-docker/tasks/main.yml index 4590f0a..e232eb1 100644 --- a/roles/install-docker/tasks/main.yml +++ b/roles/install-docker/tasks/main.yml @@ -79,7 +79,8 @@ - name: Place admin users in docker group user: - name: "{{ item }}" + name: "{{ item.logname }}" groups: docker append: yes - with_items: "{{ docker_users }}" + when: item.docker == true + with_items: "{{ users }}" diff --git a/roles/users/tasks/main.yml b/roles/users/tasks/main.yml new file mode 100644 index 0000000..2a2930e --- /dev/null +++ b/roles/users/tasks/main.yml @@ -0,0 +1,40 @@ +--- + +- name: Ensure sudo is installed + package: + name: + - sudo + state: present + +- name: Configure group sudo for sudoers without password + lineinfile: + path: /etc/sudoers + state: present + regexp: '^%sudo\s' + line: '%sudo ALL=(ALL) NOPASSWD: ALL' + validate: /usr/sbin/visudo -cf %s + +- name: Add users | create users' shell and home dir + user: + name: "{{ item.logname }}" + shell: /bin/bash + createhome: yes + comment: "{{ item.viewname }}" + with_items: "{{ users }}" + +- name: Add authorized keys for user + authorized_key: + user: "{{ item.0.logname }}" + key: "{{ item.1 }}" + state: present + with_subelements: + - "{{ users }}" + - ssh_pub + +- name: Place user in sudo group + user: + name: "{{ item.logname }}" + groups: sudo + append: yes + when: item.sudo == true + with_items: "{{ users }}" diff --git a/users/alex_authorized_keys b/users/alex_authorized_keys deleted file mode 100644 index e3269f9..0000000 --- a/users/alex_authorized_keys +++ /dev/null @@ -1,6 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVZPAE3XE8Ek1Ji4sCIHxLVx+bi2qpsTSsYhBqtYysnFn9AHJj14BR59D0Si05sfVkmL4OQoo7Q98oIxy33PgtqoUfgXk9dc7dlsye3t/gsAb25ABnqG/ZYe65nZLN7BzRM1/QZIbd6sSu6eXrNFCh0ikB5se4zgVkDO8t6h2dnz4FvTuIM2Bi/PnIJTqb8+uLQE1vS3A7tTx100ZKXxr81dlo2Y1JBP6WrS1W1IyFiG6wofl2XTY02ssyoENQyR89lLMJYKvm5xlhL/L69gtMsqIX9UBQFk8Rpq04ZIwN6b0K4R142GZvxdJNdQULgtI3gPkKgH7FDoFsRHNA6b/9 adahl@ada -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDvczlb1+9d1BjuLk5ZcQt2Z0Dh61Vg91i47tM48CN2koJ4I/9vgN37l6mnr383zD8kQkXDGmCYpXOa48WocyyUuP3h75DCjANYcWOsohQfF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eFTTcO34DJNAVIQtq9nb8Ev7s8Bjz3VR7/LS4kQlyB6dp1RLuObPYRafY0695lja4lwgy7iY1OAYCNM71OYyyztcoHEz3fGO4tzNx5Z1tI9zLpS1Wr7ENeKOKBqmFIgZno67Gq+NZr3LHNvnvAsbMsZXOdnld0LmG0Um35WEN60UYz3k6QUYBfaYrHnX2OP9auK5QDnd2jVTdNLRbBus7VtIsCfK3szLa+dFyd/ISPCB/YsZj1i0WmO766Y4GqFTZhIZUok4JuU8pl/7Y9CSKRMx4sp/3LYIAyOsL5EJxmg3fEfYsRK0gb alex@toshy -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGmU7MfOFuc6z5Vbwh4CbBFSg19f8B9rUO2ITjgmEvkY alex@lemmy diff --git a/users/tux_authorized_keys b/users/tux_authorized_keys deleted file mode 100644 index c78c03d..0000000 --- a/users/tux_authorized_keys +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvxbl9eiBojG2zKw2eSftwaMpA4XeONJpPK++WBUBJi+4RhvtN+8YX55cGsRlAA2pvW1a6hxjuR/NEA0+EAZ8ueNaOrMJjHvuUSzO76YF1gHlusAbhYvNl4EYZz/lkrFM4oaa/4/WirgUvSKnpPQx2YgX/AEkIwzk6nQLve+NmijkWdWzaww5snjbAEsgo+iEqeLPRfzbxX4Esp8bqFy3qD0SGgJM8iWlUaWCoQI1HhU4lVBtwdR6cJQ3QnmhUidRLOpIpX1sBRM8Cnwc5g2u3OpsaxPd77+5hXtxKjQUby/YLGmr6L2x1tWYqkV+GZA0Lh3fwM0BjDVT/Y/a+HUVh tux@netz39.de