Ansible playbook to add users with ssh keys and sudo
Запись создана 3 декабря, 2024
# yamllint disable rule:line-length --- - name: Add admin users hosts: all gather_facts: true become: true tasks: - name: Create account ansible.builtin.user: name: "{{ item.name }}" groups: "sudo" shell: /bin/bash append: true with_items: "{{ users }}" - name: Set authorized key taken from file ansible.posix.authorized_key: user: "{{ item.name }}" exclusive: true key: "{{ item.ssh_pub_key }}" with_items: "{{ users }}" - name: Add user to sudoers community.general.sudoers: name: "{{ item.name }}" state: present user: "{{ item.name }}" commands: 'ALL' nopassword: true with_items: "{{ users }}" vars: users: - name: mihael ssh_pub_key: "ssh-rsa AAAAB......" - name: maria ssh_pub_key: "ssh-rsa AAAAB......"
Схожие темы
» Запись из раздела Несортированное | Комментировать
Комментарии
Ответить