This commit is contained in:
parent
7e7c25c7af
commit
392a2a1c6c
@ -3,33 +3,39 @@
|
||||
|
||||
- name: Detect debian
|
||||
ansible.builtin.raw: cat /etc/os-release|grep Debian||true
|
||||
changed_when: false
|
||||
register: debian
|
||||
|
||||
- name: Detect Rocky
|
||||
ansible.builtin.raw: cat /etc/os-release|grep rocky||true
|
||||
changed_when: false
|
||||
register: rocky
|
||||
|
||||
- name: Detect arch
|
||||
ansible.builtin.raw: cat /etc/os-release|grep Arch||true
|
||||
changed_when: false
|
||||
register: arch
|
||||
|
||||
- name: Install python for rocky
|
||||
ansible.builtin.raw: dnf install python3 --assumeyes
|
||||
changed_when: false
|
||||
when: rocky.stdout
|
||||
|
||||
- name: Install python for debian
|
||||
ansible.builtin.raw: apt install python3 --assume-yes
|
||||
changed_when: false
|
||||
when: debian.stdout
|
||||
|
||||
- name: Install python on arch
|
||||
ansible.builtin.raw: pacman -Sy python --noconfirm
|
||||
changed_when: false
|
||||
when: arch.stdout
|
||||
|
||||
- name: Add local repo to mirrorlist
|
||||
become: true
|
||||
lineinfile:
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/pacman.d/mirrorlist
|
||||
line: "Server= {{system_arch_local_mirror}}/$repo/os/$arch"
|
||||
line: 'Server= {{ system_arch_local_mirror }}/$repo/os/$arch'
|
||||
state: present
|
||||
insertbefore: BOF
|
||||
when: system_arch_local_mirror is defined and arch.stdout
|
||||
@ -75,56 +81,56 @@
|
||||
- 'ansible_os_family'
|
||||
|
||||
- name: Zsh install
|
||||
package:
|
||||
ansible.builtin.package:
|
||||
state: present
|
||||
name: zsh
|
||||
update_cache: true # not required. Whether or not to refresh the master package lists. This can be run as part of a package installation or as a separate step.
|
||||
update_cache: true
|
||||
|
||||
- name: Inetutils install
|
||||
package:
|
||||
ansible.builtin.package:
|
||||
state: present
|
||||
name: inetutils
|
||||
when: arch.stdout
|
||||
|
||||
- name: Sudoers install
|
||||
package:
|
||||
state: present # not required. choices: absent;latest;present. Desired state of the package.
|
||||
name: sudo # not required. Name or list of names of the packages to install, upgrade, or remove.
|
||||
ansible.builtin.package:
|
||||
state: present
|
||||
name: sudo
|
||||
|
||||
- name: Create profil
|
||||
user:
|
||||
name: "ansible" # required. Name of the user to create, remove or modify.
|
||||
create_home: yes # not required. Unless set to C(no), a home directory will be made for the user when the account is created or if the home directory does not exist.,Changed from C(createhome) to C(create_home) in version 2.5.
|
||||
system: no # not required. When creating an account C(state=present), setting this to C(yes) makes the user a system account. This setting cannot be changed on existing users.
|
||||
state: present # not required. choices: absent;present. Whether the account should exist or not, taking action if the state is different from what is stated.
|
||||
ssh_key_file: .ssh/id_rsa # not required. Optionally specify the SSH key filename. If this is a relative filename then it will be relative to the user's home directory.
|
||||
ansible.builtin.user:
|
||||
name: 'ansible'
|
||||
create_home: true
|
||||
system: false
|
||||
state: present
|
||||
ssh_key_file: .ssh/id_rsa
|
||||
shell: /bin/bash
|
||||
|
||||
- name: Set sudoers right
|
||||
lineinfile:
|
||||
dest: "/etc/sudoers.d/ansible"
|
||||
regexp: "{{ item.regexp }}"
|
||||
line: "{{ item.line }}"
|
||||
state: "present"
|
||||
create: True
|
||||
owner: "root"
|
||||
group: "root"
|
||||
mode: "0440"
|
||||
ansible.builtin.lineinfile:
|
||||
dest: '/etc/sudoers.d/ansible'
|
||||
regexp: '{{ item.regexp }}'
|
||||
line: '{{ item.line }}'
|
||||
state: 'present'
|
||||
create: true
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
mode: '0440'
|
||||
validate: 'visudo -cf "%s"'
|
||||
with_items:
|
||||
- regexp: '^ansible\s'
|
||||
line: "ansible ALL = (ALL) NOPASSWD:ALL"
|
||||
line: 'ansible ALL = (ALL) NOPASSWD:ALL'
|
||||
|
||||
- name: Ensure /etc/sudoers includes /etc/sudoers.d
|
||||
lineinfile:
|
||||
dest: "/etc/sudoers"
|
||||
ansible.builtin.lineinfile:
|
||||
dest: '/etc/sudoers'
|
||||
regexp: '^#includedir\s+/etc/sudoers.d$'
|
||||
line: "#includedir /etc/sudoers.d"
|
||||
state: "present"
|
||||
line: '#includedir /etc/sudoers.d'
|
||||
state: 'present'
|
||||
validate: 'visudo -cf "%s"'
|
||||
|
||||
- name: Set authorized key taken from file
|
||||
authorized_key:
|
||||
user: "ansible"
|
||||
ansible.posix.authorized_key:
|
||||
user: 'ansible'
|
||||
state: present
|
||||
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
|
||||
|
Loading…
Reference in New Issue
Block a user