-
-
Notifications
You must be signed in to change notification settings - Fork 49
/
main.yml
117 lines (101 loc) · 2.82 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
- name: Get the current kernel release.
command: uname -r
changed_when: false
register: kernel_release
- name: Set the appropriate libselinux package for RHEL 8.
set_fact:
packer_rhel_libselinux_package: python3-libselinux
when: ansible_distribution_major_version == '8'
- name: Ensure necessary packages are installed.
yum:
name:
- wget
- perl
- cpp
- gcc
- make
- bzip2
- kernel-headers
- kernel-devel
- "kernel-devel-{{ kernel_release.stdout }}"
- "{{ packer_rhel_libselinux_package }}"
- elfutils-libelf-devel
- cifs-utils
state: present
# Fix slow DNS.
- name: Fix slow DNS (adapted from Bento).
lineinfile:
dest: /etc/sysconfig/network
regexp: '^RES_OPTIONS'
line: 'RES_OPTIONS="single-request-reopen"'
state: present
- name: Restart network service (RHEL < 8).
service: name=network state=restarted
when: ansible_distribution_major_version < '8'
# SSH daemon configuration.
- name: Configure SSH daemon.
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
state: present
with_items:
- regexp: '^UseDNS'
line: 'UseDNS no'
- regexp: '^GSSAPIAuthentication'
line: 'GSSAPIAuthentication no'
# Vagrant SSH configuration.
- name: Configure Vagrant .ssh directory.
file:
path: /home/vagrant/.ssh
state: directory
owner: vagrant
group: vagrant
mode: 0700
- name: Get Vagrant's public key.
get_url:
url: https://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub
dest: /home/vagrant/.ssh/authorized_keys
owner: vagrant
group: vagrant
mode: 0600
# VirtualBox tools installation.
- name: Check if VirtualBox is running the guest VM.
stat: path=/home/vagrant/.vbox_version
register: virtualbox_check
- include_tasks: virtualbox.yml
when: virtualbox_check.stat.exists
# VMware tools installation.
- name: Check if VMWare is running the guest VM.
shell: "cat /proc/scsi/scsi | grep VMware"
changed_when: false
failed_when: false
register: vmware_check
- include_tasks: vmware.yml
when: vmware_check.rc == 0
# Cleanup tasks.
- name: Remove unneeded packages.
yum:
name:
- cpp
- kernel-devel
- kernel-headers
state: absent
- name: Clean up yum.
command: yum clean all
changed_when: true
- name: Remove any remnants of VirtualBox ISOs.
shell: rm -rf VBoxGuestAdditions_*.iso VBoxGuestAdditions_*.iso.?
tags: ['skip_ansible_lint']
- name: Remove RedHat interface persistence (step 1).
command: rm -f /etc/udev/rules.d/70-persistent-net.rules
tags: ['skip_ansible_lint']
- name: Remove RedHat interface persistence (step 2).
lineinfile:
dest: /etc/sysconfig/network-scripts/ifcfg-eth0
regexp: "{{ item }}"
state: absent
with_items:
- '^HWADDR'
- '^UUID'