Initial commit
This commit is contained in:
commit
bd5282ad87
3 changed files with 31 additions and 0 deletions
1
defaults/main.yml
Normal file
1
defaults/main.yml
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
rootpath: ''
|
||||||
20
tasks/main.yml
Normal file
20
tasks/main.yml
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
- name: install dbus (needed to set the hostname with systemd)
|
||||||
|
apt:
|
||||||
|
pkg: dbus
|
||||||
|
when: rootpath == ""
|
||||||
|
|
||||||
|
- name: set hostname with systemd
|
||||||
|
hostname:
|
||||||
|
name: "{{ inventory_hostname }}"
|
||||||
|
when: rootpath == ""
|
||||||
|
|
||||||
|
- name: customize vm image hostname
|
||||||
|
copy:
|
||||||
|
dest: "{{ rootpath }}/etc/hostname"
|
||||||
|
content: '{{ inventory_hostname_short }}'
|
||||||
|
|
||||||
|
- name: customize vm image hosts file
|
||||||
|
template:
|
||||||
|
src: hosts.j2
|
||||||
|
dest: "{{ rootpath }}/etc/hosts"
|
||||||
|
|
||||||
10
templates/hosts.j2
Normal file
10
templates/hosts.j2
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
127.0.0.1 localhost
|
||||||
|
::1 localhost ip6-localhost ip6-loopback
|
||||||
|
ff02::1 ip6-allnodes
|
||||||
|
ff02::2 ip6-allrouters
|
||||||
|
|
||||||
|
{% for n in vm['nics']|default([]) %}
|
||||||
|
{% for i in vm['nics'][n].protocol if vm['nics'][n].protocol[i].type == "static" %}
|
||||||
|
{{vm['nics'][n].protocol[i].options['address']}} {{ inventory_hostname }} {{ inventory_hostname_short }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue