83 lines
2.2 KiB
YAML
83 lines
2.2 KiB
YAML
---
|
|
# tasks file for common
|
|
|
|
- name: include assert.yml
|
|
import_tasks: assert.yml
|
|
run_once: yes
|
|
delegate_to: localhost
|
|
|
|
- name: install requirements
|
|
ansible.builtin.package:
|
|
name: "{{ common_requirements }}"
|
|
state: present
|
|
|
|
- name: check for network manager
|
|
ansible.builtin.stat:
|
|
path: /etc/NetworkManager/NetworkManager.conf
|
|
register: common_check_for_network_manager
|
|
|
|
- name: set nameserver
|
|
block:
|
|
- name: set nameserver in resolv.conf
|
|
block:
|
|
- name: set nameserver in resolv.conf
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/resolv.conf
|
|
line: "nameserver {{ item }}"
|
|
mode: "0644"
|
|
loop: "{{ common_nameservers }}"
|
|
notify:
|
|
- gather facts
|
|
when:
|
|
- not common_check_for_network_manager.stat.exists
|
|
- ansible_connection != "docker"
|
|
|
|
rescue:
|
|
- name: comfort users
|
|
ansible.builtin.debug:
|
|
msg:
|
|
- "The file /etc/resolve.conf could not be modified."
|
|
- "This is likely because it is mapped from the Docker host to the Docker container."
|
|
|
|
- name: set nameservers in network manager
|
|
community.general.ini_file:
|
|
path: /etc/NetworkManager/conf.d/dnsservers.conf
|
|
section: global-dns-domain-*
|
|
option: servers
|
|
value: "{{ common_nameservers | join(',') }}"
|
|
mode: "0644"
|
|
when:
|
|
- common_check_for_network_manager.stat.exists
|
|
notify:
|
|
- reload network manager
|
|
- gather facts
|
|
when:
|
|
- common_nameservers is defined
|
|
|
|
- name: flush handlers
|
|
ansible.builtin.meta: flush_handlers
|
|
|
|
- name: set hostname
|
|
ansible.builtin.hostname:
|
|
name: "{{ common_hostname }}"
|
|
when:
|
|
- ansible_connection != "docker"
|
|
notify:
|
|
- reboot
|
|
|
|
- name: fill /etc/hosts
|
|
block:
|
|
- name: fill /etc/hosts
|
|
ansible.builtin.template:
|
|
src: hosts.j2
|
|
dest: /etc/hosts
|
|
mode: "0644"
|
|
rescue:
|
|
- name: comfort users
|
|
ansible.builtin.debug:
|
|
msg:
|
|
- "The file /etc/hosts could not be modified."
|
|
- "This is likely because it is mapped from the Docker host to the Docker container."
|
|
when:
|
|
- ansible_connection != "docker"
|