Ubuntu 20.04 on QEmu working
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
- name: clean yum history
|
||||
become: true
|
||||
shell: |-
|
||||
set -e
|
||||
yum --enablerepo=epel clean all
|
||||
yum history new
|
||||
truncate -c -s 0 /var/log/yum.log
|
||||
@@ -0,0 +1,8 @@
|
||||
- name: remove unnecessesary packages
|
||||
become: true
|
||||
package:
|
||||
name:
|
||||
- perl
|
||||
- gcc
|
||||
- kernel-devel
|
||||
state: absent
|
||||
@@ -0,0 +1,11 @@
|
||||
- name: remove unnecessesary packages
|
||||
become: true
|
||||
package:
|
||||
name:
|
||||
- make
|
||||
- perl
|
||||
- gcc
|
||||
- kernel-devel
|
||||
- net-tools
|
||||
- bzip2
|
||||
state: absent
|
||||
@@ -0,0 +1,4 @@
|
||||
- name: clean up Fedora
|
||||
become: true
|
||||
command: dnf clean all
|
||||
when: ansible_facts.pkg_mgr not in ['atomic_container']
|
||||
@@ -0,0 +1,3 @@
|
||||
- name: clean apt files
|
||||
become: true
|
||||
command: apt-get clean
|
||||
@@ -0,0 +1,8 @@
|
||||
- name: cleanup
|
||||
include_tasks: "{{ distro }}"
|
||||
loop:
|
||||
- "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml"
|
||||
- "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}.yml"
|
||||
when: distro is file
|
||||
loop_control:
|
||||
loop_var: distro
|
||||
@@ -0,0 +1,16 @@
|
||||
- become: true
|
||||
block:
|
||||
- name: install epel-release
|
||||
package:
|
||||
name: epel-release
|
||||
state: present
|
||||
|
||||
- name: disable epel
|
||||
ini_file:
|
||||
path: /etc/yum.repos.d/epel.repo
|
||||
section: epel
|
||||
option: enabled
|
||||
value: "0"
|
||||
create: false
|
||||
when: >
|
||||
ansible_facts['distribution'] in ['CentOS', 'RHEL']
|
||||
@@ -0,0 +1,16 @@
|
||||
- name: load version information
|
||||
include_vars: "{{ item }}"
|
||||
loop:
|
||||
- "{{ role_path }}/vars/{{ ansible_facts['os_family'] }}.yml"
|
||||
- "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}.yml"
|
||||
- "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml"
|
||||
- "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_version'] }}.yml"
|
||||
when: item is file
|
||||
|
||||
- name: modify init file
|
||||
become: true
|
||||
replace:
|
||||
path: "{{ init_file }}"
|
||||
replace: "{{ init_replace }}"
|
||||
regexp: "{{ init_regexp }}"
|
||||
when: init_file is defined
|
||||
@@ -0,0 +1,3 @@
|
||||
init_file: /etc/sysconfig/init
|
||||
init_regexp: "^ACTIVE_CONSOLES=.*$"
|
||||
init_replace: ACTIVE_CONSOLES=/dev/tty1
|
||||
@@ -0,0 +1,3 @@
|
||||
init_file: /etc/default/console-setup
|
||||
init_regexp: '^(ACTIVE_CONSOLES="/dev/tty).*'
|
||||
init_replace: \g<1>1
|
||||
@@ -0,0 +1,9 @@
|
||||
- name: update locale info
|
||||
become: true
|
||||
shell: |
|
||||
set -e
|
||||
localedef --list-archive | grep -a -v en_US.utf8 | xargs sudo localedef --delete-from-archive
|
||||
cp /usr/lib/locale/locale-archive{,.tmpl}
|
||||
build-locale-archive
|
||||
when: >
|
||||
ansible_facts['distribution'] in ['CentOS']
|
||||
@@ -0,0 +1,69 @@
|
||||
- name: load vars, if needed
|
||||
include_vars: "{{ item }}"
|
||||
loop:
|
||||
- "{{ role_path }}/vars/default.yml"
|
||||
- "{{ role_path }}/vars/{{ ansible_facts.distribution }}.yml"
|
||||
- "{{ role_path }}/vars/{{ ansible_facts.distribution }}_{{ ansible_facts.distribution_major_version }}.yml"
|
||||
when: item is file
|
||||
|
||||
- name: remove cloud-init
|
||||
become: true
|
||||
package:
|
||||
name: cloud-init
|
||||
state: absent
|
||||
when: ansible_facts.pkg_mgr not in ['atomic_container']
|
||||
|
||||
- name: get build time
|
||||
become: true
|
||||
copy:
|
||||
content: "{{ ansible_facts.date_time.date }}"
|
||||
dest: /etc/vagrant_box_build_time
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
||||
- name: create .ssh directory
|
||||
file:
|
||||
path: "{{ ansible_user_dir }}/.ssh"
|
||||
state: directory
|
||||
mode: "0700"
|
||||
|
||||
- name: fetch authorized_keys
|
||||
get_url:
|
||||
mode: "0600"
|
||||
dest: "{{ ansible_user_dir }}/.ssh/authorized_keys"
|
||||
url: https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub
|
||||
|
||||
- block:
|
||||
- name: configure sshd
|
||||
lineinfile:
|
||||
line: UseDNS no
|
||||
path: /etc/ssh/sshd_config
|
||||
|
||||
- name: check for the sshd_config.d directory
|
||||
stat:
|
||||
path: /etc/ssh/sshd_config.d
|
||||
register: _vagrant_sshd_config_d
|
||||
|
||||
- name: be sure that sshd is configured properly to accept the pubkey
|
||||
copy:
|
||||
content: PubkeyAcceptedKeyTypes +ssh-rsa
|
||||
mode: "0600"
|
||||
owner: root
|
||||
group: root
|
||||
dest: /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf
|
||||
when: _vagrant_sshd_config_d.stat.exists
|
||||
|
||||
- name: enable sshd
|
||||
service:
|
||||
name: "{{ vagrant_ssh_service_name }}"
|
||||
state: started
|
||||
enabled: true
|
||||
# Fedora 31 has a bug in systemd with kernel >= 5.8 that makes us
|
||||
# unable to determine state of the service. However, if we were able
|
||||
# to connect to it to run this Ansible, then we clearly are up
|
||||
# and running and we can safely ignore this error
|
||||
ignore_errors: >-
|
||||
{{ ansible_facts.distribution == 'Fedora' and
|
||||
ansible_facts.distribution_major_version == '31' }}
|
||||
become: true
|
||||
@@ -0,0 +1 @@
|
||||
vagrant_ssh_service_name: ssh
|
||||
@@ -0,0 +1 @@
|
||||
vagrant_ssh_service_name: sshd
|
||||
@@ -0,0 +1,27 @@
|
||||
- name: install build deps for virtualbox addons
|
||||
become: true
|
||||
package:
|
||||
name: "{{ virtualbox_packages }}"
|
||||
state: present
|
||||
|
||||
- name: start services
|
||||
become: true
|
||||
service:
|
||||
name: "{{ item }}"
|
||||
state: started
|
||||
enabled: true
|
||||
loop: "{{ virtualbox_services }}"
|
||||
|
||||
- name: mount iso file
|
||||
become: true
|
||||
command: "{{ item }}"
|
||||
changed_when: false
|
||||
loop:
|
||||
- mount -o loop,ro {{ ansible_user_dir }}/VBoxGuestAdditions.iso /mnt
|
||||
- /mnt/VBoxLinuxAdditions.run
|
||||
- umount /mnt
|
||||
|
||||
- name: remove iso
|
||||
file:
|
||||
name: "{{ ansible_user_dir }}/VBoxGuestAdditions.iso"
|
||||
state: absent
|
||||
@@ -0,0 +1,8 @@
|
||||
virtualbox_packages:
|
||||
- bzip2
|
||||
- dkms
|
||||
- kernel-devel
|
||||
- make
|
||||
- perl
|
||||
virtualbox_services:
|
||||
- dkms
|
||||
@@ -0,0 +1,7 @@
|
||||
virtualbox_packages:
|
||||
- bzip2
|
||||
- dkms
|
||||
- kernel-devel
|
||||
- make
|
||||
virtualbox_services:
|
||||
- dkms
|
||||
@@ -0,0 +1,5 @@
|
||||
virtualbox_packages:
|
||||
- dkms
|
||||
- make
|
||||
virtualbox_services:
|
||||
- dkms
|
||||
@@ -0,0 +1,5 @@
|
||||
- name: create hgfs dir
|
||||
become: true
|
||||
file:
|
||||
state: directory
|
||||
path: /mnt/hgfs
|
||||
@@ -0,0 +1,45 @@
|
||||
- name: create mount point
|
||||
become: true
|
||||
file:
|
||||
path: /mnt/vmware
|
||||
state: directory
|
||||
|
||||
- name: mount iso file
|
||||
become: true
|
||||
command: mount -o loop,ro {{ ansible_user_dir }}/linux.iso /mnt/vmware
|
||||
|
||||
- name: create tmp dir
|
||||
file:
|
||||
path: /tmp/vmware
|
||||
state: directory
|
||||
|
||||
- name: untar tools
|
||||
command: |
|
||||
set -ex
|
||||
tar zxf /mnt/vmware/VMWareTools-*.tar.gz -C /tmp/vmware
|
||||
sudo /tmp/vmware/vmware-tools-distrib/vmware-install.pl --default --force-install
|
||||
rm -r /tmp/vmware
|
||||
sudo umount /mnt/vmware
|
||||
changed_when: false
|
||||
|
||||
- name: remove files
|
||||
become: true
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- /mnt/vmware
|
||||
- "{{ ansible_user_dir }}/linux.iso"
|
||||
|
||||
- name: add content to /etc/vmware-tools/locations
|
||||
blockinfile:
|
||||
block: |
|
||||
remove_answer ENABLE_VGAUTH
|
||||
answer ENABLE_VGAUTH no
|
||||
remove_answer ENABLE_VMBLOCK
|
||||
answer ENABLE_VMBLOCK no
|
||||
|
||||
- name: finish up installs
|
||||
become: true
|
||||
command: /usr/bin/vmware-config-tools.pl --default --skip-stop-abort
|
||||
changed_when: false
|
||||
@@ -0,0 +1,25 @@
|
||||
- name: read variables
|
||||
include_vars: "{{ item }}"
|
||||
loop:
|
||||
- "{{ role_path }}/vars/{{ ansible_facts.distribution }}.yml"
|
||||
- "{{ role_path }}/vars/{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml"
|
||||
when: item is file
|
||||
|
||||
- name: install vmware related packages
|
||||
become: true
|
||||
package:
|
||||
name: "{{ vmware_packages }}"
|
||||
state: present
|
||||
|
||||
- name: modern systems
|
||||
import_tasks: has_package.yml
|
||||
when: >-
|
||||
ansible_distribution_name == 'fedora' or
|
||||
(ansible_distribution_name == 'debian' and
|
||||
ansible_distribution_major_version > '8')
|
||||
|
||||
- name: legacy builds
|
||||
import_tasks: legacy.yml
|
||||
when: >-
|
||||
(ansible_distribution_name == 'debian' and
|
||||
ansible_distribution_major_version <= '8')
|
||||
@@ -0,0 +1,6 @@
|
||||
vmware_packages:
|
||||
- perl
|
||||
- net-tools
|
||||
- make
|
||||
- gcc
|
||||
- kernel-devel
|
||||
@@ -0,0 +1,2 @@
|
||||
vmware_packages:
|
||||
- open-vm-tools
|
||||
@@ -0,0 +1,4 @@
|
||||
vmware_packages:
|
||||
- perl
|
||||
- make
|
||||
- linux-headers-{{ ansible_architecture }}
|
||||
@@ -0,0 +1,2 @@
|
||||
vmware_packages:
|
||||
- open-vm-tools
|
||||
@@ -0,0 +1,2 @@
|
||||
vmware_packages:
|
||||
- open-vm-tools
|
||||
@@ -0,0 +1,2 @@
|
||||
vmware_packages:
|
||||
- open-vm-tools
|
||||
Reference in New Issue
Block a user