This repository has been archived on 2020-11-04. You can view files and clone it, but cannot push or open issues or pull requests.
ansible.basics/tasks/main.yml

71 lines
2.0 KiB
YAML

---
# .. vim: foldmarker=[[[,]]]:foldmethod=marker
#
# tasks file for basics
## Modify /etc/hosts {{{
- name: Config host - Set 127.0.0.1 line in hosts file
lineinfile:
dest: /etc/hosts
state: present
regexp: "^{{ ansible_lo.ipv4.address }}"
line: "{{ ansible_lo.ipv4.address }} {{ basics__hosts_localhost_content }}"
backup: yes
when: (basics__hosts_localhost_manage and
ansible_lo.ipv4.address is defined)
- name: Config host - Set ipv4 line in hosts file
lineinfile:
dest: /etc/hosts
state: present
regexp: "^{{ ansible_default_ipv4.address }}"
line: "{{ ansible_default_ipv4.address }} {{ basics__hosts_ipv4_content }}"
backup: yes
when: (basics__hosts_ipv4_manage and
ansible_default_ipv4.address is defined)
- name: Config host - Purge other lines with hostname
lineinfile:
dest: /etc/hosts
state: absent
regexp: '^(?!({{ ansible_default_ipv4.address }})).*{{ ansible_hostname }}'
backup: yes
when: (basics__hosts_ipv4_manage and
ansible_default_ipv4.address is defined)
## }}}
# Proxmox [[[1
- name: Disable modification of files by Proxmox
copy:
content: ""
dest: '{{ (item.path | dirname) + "/.pve-ignore." + (item.path | basename) }}'
with_flattened:
- '{{ basics__proxmox_disable }}'
- '{{ basics__proxmox_group_disable }}'
- '{{ basics__proxmox_host_disable }}'
when: ansible_virtualization_type == "lxc"
# Resolvconf [[[1
- name: Ensure Resolvconf required packages are in there desired state
package:
name: '{{ item }}'
state: 'present'
install_recommends: False
with_flattened:
- '{{ basics__resolvconf_packages | to_nice_json }}'
register: resolv_pkg_result
until: resolv_pkg_result is success
when: basics__resolvconf_enabled|bool
- name: Configure Resolvconf with domains
template:
src: '../templates/etc/resolvconf/resolv.conf.d/base.j2'
dest: '/etc/resolvconf/resolv.conf.d/base'
owner: root
group: root
mode: '0644'
when: basics__resolvconf_enabled|bool
notify: ['restart resolvconf service']