refactor!: switch hosts variables to a flat layout
This commit is contained in:
parent
f669dea62a
commit
779f2766f2
33 changed files with 270 additions and 322 deletions
|
@ -2,16 +2,16 @@
|
|||
- name: '[home] get user account information'
|
||||
ansible.builtin.getent:
|
||||
database: passwd
|
||||
key: "{{ common.user_account }}"
|
||||
key: "{{ common_user_account }}"
|
||||
split: ":"
|
||||
changed_when: false
|
||||
when: ansible_facts['getent_passwd'] is undefined or common.user_account not in ansible_facts['getent_passwd']
|
||||
when: ansible_facts['getent_passwd'] is undefined or common_user_account not in ansible_facts['getent_passwd']
|
||||
|
||||
- name: '[home] create common directories'
|
||||
become: true
|
||||
become_user: "{{ common.user_account }}"
|
||||
become_user: "{{ common_user_account }}"
|
||||
ansible.builtin.file:
|
||||
path: "{{ ansible_facts['getent_passwd'][common.user_account][4] }}/{{ item }}"
|
||||
path: "{{ ansible_facts['getent_passwd'][common_user_account][4] }}/{{ item }}"
|
||||
state: directory
|
||||
mode: '0750'
|
||||
loop:
|
||||
|
@ -22,19 +22,19 @@
|
|||
|
||||
- name: '[home] setup home files'
|
||||
become: true
|
||||
become_user: "{{ common.user_account }}"
|
||||
become_user: "{{ common_user_account }}"
|
||||
block:
|
||||
- name: '[home] git configuration'
|
||||
ansible.builtin.template:
|
||||
src: ../templates/home/.gitconfig.j2
|
||||
dest: "{{ ansible_facts['getent_passwd'][common.user_account][4] }}/.gitconfig"
|
||||
dest: "{{ ansible_facts['getent_passwd'][common_user_account][4] }}/.gitconfig"
|
||||
mode: '0640'
|
||||
when: common.git.enable is truthy
|
||||
when: common_git_enabled is truthy
|
||||
|
||||
- name: '[home] basic files'
|
||||
ansible.builtin.copy:
|
||||
src: "../templates/home/{{ item.name }}"
|
||||
dest: "{{ ansible_facts['getent_passwd'][common.user_account][4] }}/{{ item.name }}"
|
||||
dest: "{{ ansible_facts['getent_passwd'][common_user_account][4] }}/{{ item.name }}"
|
||||
mode: "{{ item.mode | default('0640') }}"
|
||||
loop:
|
||||
- { name: ".lessfilter", mode: '0750' }
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
---
|
||||
- name: '[setup] merge with custom vars'
|
||||
ansible.builtin.set_fact:
|
||||
common: "{{ common | combine(custom_common, recursive=recursive_combine) }}"
|
||||
changed_when: false
|
||||
|
||||
- name: '[system] setup DNS server'
|
||||
block:
|
||||
- name: disable resolv.conf updates from dhclient
|
||||
|
@ -25,7 +20,7 @@
|
|||
owner: root
|
||||
group: root
|
||||
become: true
|
||||
when: common.configure_resolv_conf is truthy
|
||||
when: common_configure_resolve_conf is truthy
|
||||
|
||||
- name: '[system] re-allow DHCP client to setup DNS resolvers'
|
||||
become: true
|
||||
|
@ -33,7 +28,7 @@
|
|||
path: /etc/dhcp/dhclient-enter-hooks.d/nodnsupdate
|
||||
state: absent
|
||||
failed_when: false
|
||||
when : common.configure_resolv_conf is falsy
|
||||
when : common_configure_resolve_conf is falsy
|
||||
|
||||
- name: '[apt] verify components of default sources'
|
||||
become: true
|
||||
|
@ -43,15 +38,15 @@
|
|||
path: '/etc/apt/sources.list'
|
||||
regexp: '^(deb((?!{{ item }}).)+)$'
|
||||
replace: '\1 {{ item }}'
|
||||
when: not common.apt.deb822_format | bool
|
||||
loop: '{{ common.apt.source_components }}'
|
||||
loop: '{{ common_apt_source_components }}'
|
||||
when: common_apt_use_deb822_format is falsy
|
||||
- name: '[apt] default deb822 debian.sources'
|
||||
ansible.builtin.replace:
|
||||
path: '/etc/apt/sources.list.d/debian.sources'
|
||||
regexp: '^(Components: ((?!{{ item }}).)+)$'
|
||||
replace: '\1 {{ item }}'
|
||||
loop: '{{ common.apt.source_components }}'
|
||||
when: common.apt.deb822_format | bool
|
||||
loop: '{{ common_apt_source_components }}'
|
||||
when: common_apt_use_deb822_format is truthy
|
||||
|
||||
- name: '[apt] install dependencies and tools'
|
||||
become: true
|
||||
|
@ -98,7 +93,7 @@
|
|||
asset_type: "{{ item.asset_type }}"
|
||||
cmds: "{{ item.cmds | default([]) }}"
|
||||
creates: "{{ item.creates | default('') }}"
|
||||
github_token: "{{ common.github_token }}"
|
||||
github_token: "{{ common_github_token }}"
|
||||
repository: "{{ item.repository }}"
|
||||
version: "{{ item.version | default('') }}"
|
||||
loop:
|
||||
|
@ -144,9 +139,9 @@
|
|||
src: ../templates/system/sysctld.local.conf.j2
|
||||
dest: /etc/sysctl.d/local.conf
|
||||
mode: '0644'
|
||||
when: common.sysctl is truthy
|
||||
when: common_sysctl_configuration is truthy
|
||||
vars:
|
||||
sysctl_values: "{{ common.sysctl }}"
|
||||
sysctl_values: "{{ common_sysctl_configuration }}"
|
||||
notify:
|
||||
- 'common : [system] reload sysctl configuration'
|
||||
|
||||
|
@ -156,8 +151,7 @@
|
|||
update_cache: true
|
||||
force_apt_get: true
|
||||
cache_valid_time: 3600
|
||||
pkg:
|
||||
"{{ common.apt.packages }}"
|
||||
pkg: "{{ common_apt_packages }}"
|
||||
|
||||
- include_tasks: home_setup.yml
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
- name: '[home] get user account information'
|
||||
ansible.builtin.getent:
|
||||
database: passwd
|
||||
key: "{{ common.user_account }}"
|
||||
key: "{{ common_user_account }}"
|
||||
split: ":"
|
||||
changed_when: false
|
||||
when: ansible_facts['getent_passwd'] is undefined or common.user_account not in ansible_facts['getent_passwd']
|
||||
when: ansible_facts['getent_passwd'] is undefined or common_user_account not in ansible_facts['getent_passwd']
|
||||
|
||||
- name: '[shell] install ZSH and dependencies'
|
||||
become: true
|
||||
|
@ -20,7 +20,7 @@
|
|||
|
||||
- name: '[shell] install custom fonts'
|
||||
become: true
|
||||
become_user: "{{ common.user_account }}"
|
||||
become_user: "{{ common_user_account }}"
|
||||
block:
|
||||
- name: '[fonts] add fonts tooling'
|
||||
become_user: root
|
||||
|
@ -34,18 +34,18 @@
|
|||
- name: '[fonts] adding fonts'
|
||||
ansible.builtin.copy:
|
||||
src: ../assets/fonts/
|
||||
dest: "{{ ansible_facts['getent_passwd'][common.user_account][4] }}/.local/share/fonts"
|
||||
dest: "{{ ansible_facts['getent_passwd'][common_user_account][4] }}/.local/share/fonts"
|
||||
mode: '0640'
|
||||
|
||||
- name: '[fonts] refresh fonts cache'
|
||||
ansible.builtin.command:
|
||||
cmd: fc-cache
|
||||
changed_when: false
|
||||
when: common.install_fonts is truthy
|
||||
when: common_install_fonts is truthy
|
||||
|
||||
- name: '[shell] install Oh-My-ZSH'
|
||||
become: true
|
||||
become_user: "{{ common.user_account }}"
|
||||
become_user: "{{ common_user_account }}"
|
||||
block:
|
||||
- name: '[omz] get install script'
|
||||
ansible.builtin.get_url:
|
||||
|
@ -56,22 +56,22 @@
|
|||
- name: '[omz] install OMZ'
|
||||
ansible.builtin.command:
|
||||
cmd: sh /tmp/zsh-install.sh --unattended
|
||||
creates: "{{ ansible_facts['getent_passwd'][common.user_account][4] }}/.oh-my-zsh"
|
||||
creates: "{{ ansible_facts['getent_passwd'][common_user_account][4] }}/.oh-my-zsh"
|
||||
|
||||
- name: '[shell] install powerlevel10k customization for OMZ'
|
||||
become: true
|
||||
become_user: "{{ common.user_account }}"
|
||||
become_user: "{{ common_user_account }}"
|
||||
ansible.builtin.git:
|
||||
repo: https://github.com/romkatv/powerlevel10k.git
|
||||
dest: "{{ ansible_facts['getent_passwd'][common.user_account][4] }}/.oh-my-zsh/custom/themes/powerlevel10k"
|
||||
dest: "{{ ansible_facts['getent_passwd'][common_user_account][4] }}/.oh-my-zsh/custom/themes/powerlevel10k"
|
||||
depth: 1
|
||||
|
||||
- name: '[home] copy zsh files'
|
||||
become: true
|
||||
become_user: "{{ common.user_account }}"
|
||||
become_user: "{{ common_user_account }}"
|
||||
ansible.builtin.copy:
|
||||
src: "../templates/home/{{ item }}"
|
||||
dest: "{{ ansible_facts['getent_passwd'][common.user_account][4] }}/{{ item }}"
|
||||
dest: "{{ ansible_facts['getent_passwd'][common_user_account][4] }}/{{ item }}"
|
||||
mode: '0640'
|
||||
loop:
|
||||
- .p10k.zsh
|
||||
|
@ -84,6 +84,6 @@
|
|||
- name: '[shell] update user shell to ZSH'
|
||||
become: true
|
||||
ansible.builtin.user:
|
||||
name: "{{ common.user_account }}"
|
||||
name: "{{ common_user_account }}"
|
||||
shell: "/usr/bin/zsh"
|
||||
state: present
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue