This commit is contained in:
parent
7e7c25c7af
commit
392a2a1c6c
@ -3,33 +3,39 @@
|
|||||||
|
|
||||||
- name: Detect debian
|
- name: Detect debian
|
||||||
ansible.builtin.raw: cat /etc/os-release|grep Debian||true
|
ansible.builtin.raw: cat /etc/os-release|grep Debian||true
|
||||||
|
changed_when: false
|
||||||
register: debian
|
register: debian
|
||||||
|
|
||||||
- name: Detect Rocky
|
- name: Detect Rocky
|
||||||
ansible.builtin.raw: cat /etc/os-release|grep rocky||true
|
ansible.builtin.raw: cat /etc/os-release|grep rocky||true
|
||||||
|
changed_when: false
|
||||||
register: rocky
|
register: rocky
|
||||||
|
|
||||||
- name: Detect arch
|
- name: Detect arch
|
||||||
ansible.builtin.raw: cat /etc/os-release|grep Arch||true
|
ansible.builtin.raw: cat /etc/os-release|grep Arch||true
|
||||||
|
changed_when: false
|
||||||
register: arch
|
register: arch
|
||||||
|
|
||||||
- name: Install python for rocky
|
- name: Install python for rocky
|
||||||
ansible.builtin.raw: dnf install python3 --assumeyes
|
ansible.builtin.raw: dnf install python3 --assumeyes
|
||||||
|
changed_when: false
|
||||||
when: rocky.stdout
|
when: rocky.stdout
|
||||||
|
|
||||||
- name: Install python for debian
|
- name: Install python for debian
|
||||||
ansible.builtin.raw: apt install python3 --assume-yes
|
ansible.builtin.raw: apt install python3 --assume-yes
|
||||||
|
changed_when: false
|
||||||
when: debian.stdout
|
when: debian.stdout
|
||||||
|
|
||||||
- name: Install python on arch
|
- name: Install python on arch
|
||||||
ansible.builtin.raw: pacman -Sy python --noconfirm
|
ansible.builtin.raw: pacman -Sy python --noconfirm
|
||||||
|
changed_when: false
|
||||||
when: arch.stdout
|
when: arch.stdout
|
||||||
|
|
||||||
- name: Add local repo to mirrorlist
|
- name: Add local repo to mirrorlist
|
||||||
become: true
|
become: true
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/pacman.d/mirrorlist
|
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
|
state: present
|
||||||
insertbefore: BOF
|
insertbefore: BOF
|
||||||
when: system_arch_local_mirror is defined and arch.stdout
|
when: system_arch_local_mirror is defined and arch.stdout
|
||||||
@ -75,56 +81,56 @@
|
|||||||
- 'ansible_os_family'
|
- 'ansible_os_family'
|
||||||
|
|
||||||
- name: Zsh install
|
- name: Zsh install
|
||||||
package:
|
ansible.builtin.package:
|
||||||
state: present
|
state: present
|
||||||
name: zsh
|
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
|
- name: Inetutils install
|
||||||
package:
|
ansible.builtin.package:
|
||||||
state: present
|
state: present
|
||||||
name: inetutils
|
name: inetutils
|
||||||
when: arch.stdout
|
when: arch.stdout
|
||||||
|
|
||||||
- name: Sudoers install
|
- name: Sudoers install
|
||||||
package:
|
ansible.builtin.package:
|
||||||
state: present # not required. choices: absent;latest;present. Desired state of the package.
|
state: present
|
||||||
name: sudo # not required. Name or list of names of the packages to install, upgrade, or remove.
|
name: sudo
|
||||||
|
|
||||||
- name: Create profil
|
- name: Create profil
|
||||||
user:
|
ansible.builtin.user:
|
||||||
name: "ansible" # required. Name of the user to create, remove or modify.
|
name: 'ansible'
|
||||||
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.
|
create_home: true
|
||||||
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.
|
system: false
|
||||||
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.
|
state: present
|
||||||
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.
|
ssh_key_file: .ssh/id_rsa
|
||||||
shell: /bin/bash
|
shell: /bin/bash
|
||||||
|
|
||||||
- name: Set sudoers right
|
- name: Set sudoers right
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
dest: "/etc/sudoers.d/ansible"
|
dest: '/etc/sudoers.d/ansible'
|
||||||
regexp: "{{ item.regexp }}"
|
regexp: '{{ item.regexp }}'
|
||||||
line: "{{ item.line }}"
|
line: '{{ item.line }}'
|
||||||
state: "present"
|
state: 'present'
|
||||||
create: True
|
create: true
|
||||||
owner: "root"
|
owner: 'root'
|
||||||
group: "root"
|
group: 'root'
|
||||||
mode: "0440"
|
mode: '0440'
|
||||||
validate: 'visudo -cf "%s"'
|
validate: 'visudo -cf "%s"'
|
||||||
with_items:
|
with_items:
|
||||||
- regexp: '^ansible\s'
|
- regexp: '^ansible\s'
|
||||||
line: "ansible ALL = (ALL) NOPASSWD:ALL"
|
line: 'ansible ALL = (ALL) NOPASSWD:ALL'
|
||||||
|
|
||||||
- name: Ensure /etc/sudoers includes /etc/sudoers.d
|
- name: Ensure /etc/sudoers includes /etc/sudoers.d
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
dest: "/etc/sudoers"
|
dest: '/etc/sudoers'
|
||||||
regexp: '^#includedir\s+/etc/sudoers.d$'
|
regexp: '^#includedir\s+/etc/sudoers.d$'
|
||||||
line: "#includedir /etc/sudoers.d"
|
line: '#includedir /etc/sudoers.d'
|
||||||
state: "present"
|
state: 'present'
|
||||||
validate: 'visudo -cf "%s"'
|
validate: 'visudo -cf "%s"'
|
||||||
|
|
||||||
- name: Set authorized key taken from file
|
- name: Set authorized key taken from file
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: "ansible"
|
user: 'ansible'
|
||||||
state: present
|
state: present
|
||||||
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
|
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
|
||||||
|
Loading…
Reference in New Issue
Block a user