Initial ansible onboard

This commit is contained in:
2024-09-24 15:19:51 +02:00
parent 7366659355
commit f445996797
492 changed files with 2214589 additions and 0 deletions
@@ -0,0 +1,10 @@
---
exclude_paths:
- .git/
- .github/
- tests/
enable_list:
- fqcn-builtins # opt-in
warn_list:
- line-length
- yaml[line-length]
+33
View File
@@ -0,0 +1,33 @@
---
# Based on ansible-lint config
extends: default
rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
colons:
max-spaces-after: -1
level: error
commas:
max-spaces-after: -1
level: error
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
max: 3
level: error
hyphens:
level: error
indentation: disable
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: disable
new-lines:
type: unix
trailing-spaces: disable
truthy: disable
@@ -0,0 +1,18 @@
---
# Copyright 2019 Alexandre Pires ( c.alexandre.pires@gmail.com )
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
libvirt_users: ["{{ ansible_env.SUDO_USER | d('root') }}"]
libvirt_pool__dir: "/srv/pools"
libvirt_ansible__pool__name: "default"
@@ -0,0 +1,23 @@
*********************************
Vagrant driver installation guide
*********************************
Requirements
============
* Vagrant
* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop
Install
=======
Please refer to the `Virtual environment`_ documentation for installation best
practices. If not using a virtual environment, please consider passing the
widely recommended `'--user' flag`_ when invoking ``pip``.
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
.. code-block:: bash
$ pip install 'molecule_vagrant'
@@ -0,0 +1,28 @@
---
- name: Converge
hosts: all
tasks:
- name: Update Package Cache (apt/Ubuntu)
become: true
ansible.builtin.apt:
update_cache: yes
changed_when: false
when: ansible_distribution == "Ubuntu"
- name: Update Package Cache (dnf/CentOS)
become: true
ansible.builtin.dnf:
update_cache: yes
changed_when: false
when: ansible_distribution == "CentOS"
- name: Update Package Cache (yum/Amazon)
become: true
ansible.builtin.yum:
update_cache: yes
changed_when: false
when: ansible_distribution == "Amazon"
- name: "Include virtualization"
ansible.builtin.include_role:
name: "virtualization"
@@ -0,0 +1,55 @@
---
dependency:
name: galaxy
enabled: true
driver:
name: vagrant
provider:
name: libvirt
provisioner:
name: ansible
config_options:
defaults:
callbacks_enabled: profile_tasks
log: true
inventory:
group_vars:
all:
ssh_allowed_zones:
- "ALL"
ssh_allowed_networks:
- "0.0.0.0/0"
host_vars: {}
platforms:
- name: jammy
box: "jaredeh/ubuntu2204-server"
box_version: "0.1.1"
interfaces:
- auto_config: true
network_name: private_network
type: dhcp
instance_raw_config_args:
# use single quotes to avoid YAML parsing as dict due to ':'
- 'vm.synced_folder ".", "/vagrant", type: "rsync"'
# Run 'uname' a provisionning step **needs 'provision: true' to work**
- 'vm.provision :shell, inline: "uname"'
# Dictionary of `config` options. Note that string values need to be
# explicitly enclosed in quotes.
config_options:
vm.boot_timeout: 600
ssh.keep_alive: yes
ssh.remote_user: 'ansible'
synced_folder: true
provider_options:
video_type: 'vga'
host: 'localhost'
uri: 'qemu:///system'
nested: true
memory: 4096
verifier:
name: ansible
lint: |
set -e
ansible-lint
scenario:
name: default
@@ -0,0 +1,10 @@
---
# This is an example playbook to execute Ansible tests.
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Example assertion
ansible.builtin.assert:
that: true
@@ -0,0 +1,4 @@
---
collections:
- community.general
- community.libvirt
@@ -0,0 +1,14 @@
- name: Ubuntu specific tasks
when: ansible_distribution == 'Ubuntu'
block:
- name: Update APT cache
become: true
ansible.builtin.apt:
update_cache: yes
cache_valid_time: 3600
- name: Install Dependencies
become: true
ansible.builtin.package:
pkg: "python3-pip"
state: present
@@ -0,0 +1,25 @@
- name: Install system packages for virtualization
become: true
ansible.builtin.package:
pkg: "{{ item }}"
state: present
loop:
- qemu-kvm
- libvirt-daemon-system
- virtinst
- libvirt-clients
- bridge-utils
- python3-libvirt
- dnsmasq
- qemu-utils
- bzip2
- libxml2-utils
- name: Install PIP packages for virtualization
become: true
ansible.builtin.pip:
name: "{{ item }}"
state: present
loop:
- lxml
@@ -0,0 +1,19 @@
---
- name: 'Install required packages for virtualization'
ansible.builtin.include_tasks: "{{ role_path }}/tasks/install.yml"
tags:
- 'role::virtualization'
- 'role::virtualization::install'
- name: 'Config virtualization support on host'
ansible.builtin.import_tasks: "{{ role_path }}/tasks/manage_config.yml"
tags:
- 'role::virtualization'
- 'role::virtualization::config'
- name: 'Restart and enable/disable virtualization service'
ansible.builtin.import_tasks: "{{ role_path }}/tasks/manage_service.yml"
tags:
- 'role::virtualization'
- 'role::virtualization::install'
- 'role::virtualization::service'
@@ -0,0 +1,16 @@
- name: Adding required users to group libvirt
become: true
ansible.builtin.user:
name: "{{ item }}"
groups:
- libvirt
append: true
loop: "{{ libvirt_users }}"
- name: Fix qemu.conf SE Linux driver
when: ansible_distribution == 'Ubuntu'
become: true
ansible.builtin.lineinfile:
dest: /etc/libvirt/qemu.conf
line: 'security_driver = "none"'
state: present
@@ -0,0 +1,6 @@
- name: Service enable/disable
become: true
ansible.builtin.service:
name: libvirtd
enabled: yes
state: started