Add vm_dns_search to hostname if set
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
when: os in ["almalinux", "rhel8", "rhel9", "rocky"] and filesystem == "xfs"
|
when: os in ["almalinux", "rhel8", "rhel9", "rocky"] and filesystem == "xfs"
|
||||||
ansible.builtin.replace:
|
ansible.builtin.replace:
|
||||||
path: /mnt/etc/fstab
|
path: /mnt/etc/fstab
|
||||||
regexp: '(xfs.*?)(attr2)'
|
regexp: "(xfs.*?)(attr2)"
|
||||||
replace: '\1allocsize=64m'
|
replace: '\1allocsize=64m'
|
||||||
|
|
||||||
- name: Replace ISO UUID entry with /dev/sr0 in fstab
|
- name: Replace ISO UUID entry with /dev/sr0 in fstab
|
||||||
@@ -18,8 +18,9 @@
|
|||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /mnt/etc/fstab
|
path: /mnt/etc/fstab
|
||||||
regexp: '^.*\/dvd.*$'
|
regexp: '^.*\/dvd.*$'
|
||||||
line: "{{ '/usr/local/install/redhat/rhel.iso /usr/local/install/redhat/dvd iso9660 loop,nofail 0 0' if hypervisor == 'vmware'
|
line:
|
||||||
else '/dev/sr0 /usr/local/install/redhat/dvd iso9660 ro,relatime,nojoliet,check=s,map=n,nofail 0 0' }}"
|
"{{ '/usr/local/install/redhat/rhel.iso /usr/local/install/redhat/dvd iso9660 loop,nofail 0 0' if hypervisor == 'vmware'
|
||||||
|
else '/dev/sr0 /usr/local/install/redhat/dvd iso9660 ro,relatime,nojoliet,check=s,map=n,nofail 0 0' }}"
|
||||||
state: present
|
state: present
|
||||||
backrefs: true
|
backrefs: true
|
||||||
|
|
||||||
@@ -68,27 +69,27 @@
|
|||||||
|
|
||||||
- name: Set hostname
|
- name: Set hostname
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
content: "{{ hostname }}"
|
content: "{{ hostname }}{% if vm_dns_search is defined and vm_dns_search | length %}.{{ vm_dns_search }}{% endif %}"
|
||||||
dest: /mnt/etc/hostname
|
dest: /mnt/etc/hostname
|
||||||
mode: '0644'
|
mode: "0644"
|
||||||
|
|
||||||
- name: Add host entry to /etc/hosts
|
- name: Add host entry to /etc/hosts
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /mnt/etc/hosts
|
path: /mnt/etc/hosts
|
||||||
line: "{{ ansible_host }} {{ hostname }}"
|
line: "{{ ansible_host }} {{ hostname }}{% if vm_dns_search is defined and vm_dns_search | length %} {{ hostname }}.{{ vm_dns_search }}{% endif %}"
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Create vconsole.conf
|
- name: Create vconsole.conf
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
content: KEYMAP=us
|
content: KEYMAP=us
|
||||||
dest: /mnt/etc/vconsole.conf
|
dest: /mnt/etc/vconsole.conf
|
||||||
mode: '0644'
|
mode: "0644"
|
||||||
|
|
||||||
- name: Create locale.conf
|
- name: Create locale.conf
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
content: LANG=en_US.UTF-8
|
content: LANG=en_US.UTF-8
|
||||||
dest: /mnt/etc/locale.conf
|
dest: /mnt/etc/locale.conf
|
||||||
mode: '0644'
|
mode: "0644"
|
||||||
|
|
||||||
- name: SSH permit Password
|
- name: SSH permit Password
|
||||||
ansible.builtin.replace:
|
ansible.builtin.replace:
|
||||||
@@ -158,7 +159,7 @@
|
|||||||
when: os | lower == "archlinux" and filesystem != "btrfs"
|
when: os | lower == "archlinux" and filesystem != "btrfs"
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /mnt/etc/mkinitcpio.conf
|
path: /mnt/etc/mkinitcpio.conf
|
||||||
regexp: '^(HOOKS=.*block)(?!.*lvm2)(.*)'
|
regexp: "^(HOOKS=.*block)(?!.*lvm2)(.*)"
|
||||||
line: '\1 lvm2\2'
|
line: '\1 lvm2\2'
|
||||||
backrefs: true
|
backrefs: true
|
||||||
|
|
||||||
@@ -177,8 +178,9 @@
|
|||||||
- name: Append vim configurations to vimrc
|
- name: Append vim configurations to vimrc
|
||||||
failed_when: false
|
failed_when: false
|
||||||
ansible.builtin.blockinfile:
|
ansible.builtin.blockinfile:
|
||||||
path: "{{ '/mnt/etc/vim/vimrc' if os | lower in ['debian11', 'debian12', 'ubuntu', 'ubuntu-lts']
|
path:
|
||||||
else '/mnt/etc/vimrc' }}"
|
"{{ '/mnt/etc/vim/vimrc' if os | lower in ['debian11', 'debian12', 'ubuntu', 'ubuntu-lts']
|
||||||
|
else '/mnt/etc/vimrc' }}"
|
||||||
block: |
|
block: |
|
||||||
set encoding=utf-8
|
set encoding=utf-8
|
||||||
set number
|
set number
|
||||||
@@ -199,7 +201,7 @@
|
|||||||
vm.dirty_ratio=10
|
vm.dirty_ratio=10
|
||||||
vm.page-cluster=10
|
vm.page-cluster=10
|
||||||
marker: ""
|
marker: ""
|
||||||
mode: '0644'
|
mode: "0644"
|
||||||
|
|
||||||
- name: Create zram config
|
- name: Create zram config
|
||||||
when: os not in ['debian11', 'rhel8']
|
when: os not in ['debian11', 'rhel8']
|
||||||
@@ -211,13 +213,13 @@
|
|||||||
compression-algorithm = zstd
|
compression-algorithm = zstd
|
||||||
swap-priority = 100
|
swap-priority = 100
|
||||||
fs-type = swap
|
fs-type = swap
|
||||||
mode: '0644'
|
mode: "0644"
|
||||||
|
|
||||||
- name: Copy Custom Shell config
|
- name: Copy Custom Shell config
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: custom.sh.j2
|
src: custom.sh.j2
|
||||||
dest: /mnt/etc/profile.d/custom.sh
|
dest: /mnt/etc/profile.d/custom.sh
|
||||||
mode: '0644'
|
mode: "0644"
|
||||||
|
|
||||||
- name: Create login banner
|
- name: Create login banner
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -230,7 +232,7 @@
|
|||||||
**************************************************************
|
**************************************************************
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: '0644'
|
mode: "0644"
|
||||||
loop:
|
loop:
|
||||||
- /mnt/etc/issue
|
- /mnt/etc/issue
|
||||||
- /etc/issue.net
|
- /etc/issue.net
|
||||||
@@ -272,7 +274,7 @@
|
|||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /mnt/etc/NetworkManager/conf.d/10-globally-managed-devices.conf
|
path: /mnt/etc/NetworkManager/conf.d/10-globally-managed-devices.conf
|
||||||
state: touch
|
state: touch
|
||||||
mode: '0644'
|
mode: "0644"
|
||||||
|
|
||||||
- name: Setup user account
|
- name: Setup user account
|
||||||
block:
|
block:
|
||||||
@@ -307,7 +309,7 @@
|
|||||||
when: os | lower in ['almalinux', 'fedora', 'rhel8', 'rhel9', 'rocky']
|
when: os | lower in ['almalinux', 'fedora', 'rhel8', 'rhel9', 'rocky']
|
||||||
block:
|
block:
|
||||||
- name: Relabel the filesystem
|
- name: Relabel the filesystem
|
||||||
when: os | lower != "fedora"
|
when: os | lower != "fedora"
|
||||||
ansible.builtin.command: "arch-chroot /mnt /sbin/fixfiles onboot"
|
ansible.builtin.command: "arch-chroot /mnt /sbin/fixfiles onboot"
|
||||||
changed_when: result.rc == 0
|
changed_when: result.rc == 0
|
||||||
register: result
|
register: result
|
||||||
|
|||||||
Reference in New Issue
Block a user