-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure & create OS image using ansible provisioner
- Loading branch information
0 parents
commit 1b10dbe
Showing
8 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
|
||
[*] | ||
|
||
# Change these settings to your own preference | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
# We recommend you to keep these unchanged | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vagrant/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# hetzner OS image for debian 9 | ||
|
||
A provisioner for a vagrant box in order to create an OS image for debian 9 that | ||
can be used with the hetzner installimage tool. | ||
|
||
## Notes | ||
|
||
hetzner offers a standard image for debian 9. Unfortunately it does not include support | ||
for the latest intel network adapters used dedicated hosts of PX series (and probably others). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Vagrant.configure("2") do |config| | ||
config.vm.box = "bento/debian-9.11" | ||
|
||
# Run Ansible from the Vagrant VM | ||
config.vm.provision "ansible_local" do |ansible| | ||
ansible.verbose = "vv" | ||
ansible.playbook = "playbooks/vagrant.yml" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
intel_driver_module: e1000e | ||
intel_driver_version: 3.6.0 | ||
intel_driver_download_location: https://downloadmirror.intel.com/15817/eng/{{ intel_driver_module }}-{{ intel_driver_version }}.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# If you change this file, run 'update-grub' afterwards to update | ||
# /boot/grub/grub.cfg. | ||
# For full documentation of the options in this file, see: | ||
# info -f grub -n 'Simple configuration' | ||
|
||
GRUB_DEFAULT=0 | ||
GRUB_TIMEOUT=5 | ||
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` | ||
GRUB_CMDLINE_LINUX_DEFAULT="nomodeset consoleblank=0" | ||
GRUB_CMDLINE_LINUX="net.ifnames=1 biosdevname=0 debian-installer=en_US.UTF-8" | ||
|
||
# Uncomment to enable BadRAM filtering, modify to suit your needs | ||
# This works with Linux (no patch required) and with any kernel that obtains | ||
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...) | ||
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef" | ||
|
||
# Uncomment to disable graphical terminal (grub-pc only) | ||
#GRUB_TERMINAL=console | ||
|
||
# The resolution used on graphical terminal | ||
# note that you can use only modes which your graphic card supports via VBE | ||
# you can see them in real GRUB with the command `vbeinfo' | ||
#GRUB_GFXMODE=640x480 | ||
|
||
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux | ||
#GRUB_DISABLE_LINUX_UUID=true | ||
|
||
# Uncomment to disable generation of recovery mode menu entries | ||
#GRUB_DISABLE_RECOVERY="true" | ||
|
||
# Uncomment to get a beep at grub start | ||
#GRUB_INIT_TUNE="480 440 1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
- name: Download intel driver for network adapter | ||
get_url: | ||
url: "{{ intel_driver_download_location }}" | ||
dest: /root/{{ intel_driver_module }}-{{ intel_driver_version }}.tar.gz | ||
mode: '0440' | ||
|
||
- name: Extract network adapter driver | ||
unarchive: | ||
src: /root/{{ intel_driver_module }}-{{ intel_driver_version }}.tar.gz | ||
dest: /root/ | ||
remote_src: yes | ||
|
||
- name: Run command to get kernel version | ||
command: "uname -r" | ||
register: uname_output | ||
|
||
- name: Set kernel version variable | ||
set_fact: | ||
kernel_version: "{{ uname_output.stdout }}" | ||
|
||
- name: Install kernel headers | ||
apt: | ||
name: "linux-headers-{{ kernel_version }}" | ||
state: present | ||
|
||
- name: Compile network adapter driver | ||
shell: make install | ||
args: | ||
chdir: /root/{{ intel_driver_module }}-{{ intel_driver_version }}/src/ | ||
|
||
- name: Load network adapter driver module | ||
shell: modprobe {{ intel_driver_module }} | ||
|
||
- name: Add network card driver module to /etc/modules | ||
lineinfile: | ||
dest: /etc/modules | ||
regexp: '^{{ intel_driver_module }}' | ||
line: "{{ intel_driver_module }}" | ||
|
||
- name: Rename network device | ||
shell: nohup sh -c "ip link set eth0 down && ip link set eth0 name eno1 && ip link set eno1 up" | ||
|
||
- name: Copy over grub config files with enabled predictable network devices | ||
copy: | ||
src: files/grub | ||
dest: /etc/default/grub | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
|
||
- name: Update grub config | ||
shell: update-grub | ||
|
||
- name: Run command to get package timestamp | ||
command: "date +%Y%m%d%H%M%S" | ||
register: date_output | ||
|
||
- name: Set package timestamp name | ||
set_fact: | ||
package_timestamp: "{{ date_output.stdout }}" | ||
|
||
- name: Create directory for image | ||
file: | ||
path: /osimage | ||
state: directory | ||
|
||
- name: Create OS image package | ||
shell: tar zcvf Debian-911-stretch-64-custom-{{ package_timestamp }}.tar.gz /bin /boot /etc /home /lib /lib64 /media /mnt /opt /root /run /sbin /srv /tmp /usr /var | ||
args: | ||
chdir: /osimage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- hosts: all | ||
become: true | ||
vars: | ||
document_root: /vagrant | ||
www_user: vagrant | ||
www_group: vagrant | ||
pre_tasks: | ||
- name: update apt cache | ||
apt: update_cache=yes cache_valid_time=3600 | ||
roles: | ||
- debian9-hetzner |