Clean up group names. Fix mineos

This commit is contained in:
2019-12-23 10:30:50 -05:00
parent 488aa851bb
commit 793f9f0da3
49 changed files with 1041 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
# Note: need to specify extra_vars, providing ansible_ssh_user, and ansible_ssh_pass
- name: Set up IPA Client
hosts: lab-ipa-client
hosts: lab_ipa_client
become: yes
roles:
- role: debian-freeipa-client

257
library/ovirt4.py Executable file
View File

@@ -0,0 +1,257 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 Red Hat, Inc.
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
"""
oVirt dynamic inventory script
=================================
Generates dynamic inventory file for oVirt.
Script will return following attributes for each virtual machine:
- id
- name
- host
- cluster
- status
- description
- fqdn
- os_type
- template
- tags
- statistics
- devices
When run in --list mode, virtual machines are grouped by the following categories:
- cluster
- tag
- status
Note: If there is some virtual machine which has has more tags it will be in both tag
records.
Examples:
# Execute update of system on webserver virtual machine:
$ ansible -i contrib/inventory/ovirt4.py webserver -m yum -a "name=* state=latest"
# Get webserver virtual machine information:
$ contrib/inventory/ovirt4.py --host webserver
Author: Ondra Machacek (@machacekondra)
"""
import argparse
import os
import sys
from collections import defaultdict
from ansible.module_utils.six.moves import configparser
import json
try:
import ovirtsdk4 as sdk
import ovirtsdk4.types as otypes
except ImportError:
print('oVirt inventory script requires ovirt-engine-sdk-python >= 4.0.0')
sys.exit(1)
def parse_args():
"""
Create command line parser for oVirt dynamic inventory script.
"""
parser = argparse.ArgumentParser(
description='Ansible dynamic inventory script for oVirt.',
)
parser.add_argument(
'--list',
action='store_true',
default=True,
help='Get data of all virtual machines (default: True).',
)
parser.add_argument(
'--host',
help='Get data of virtual machines running on specified host.',
)
parser.add_argument(
'--pretty',
action='store_true',
default=False,
help='Pretty format (default: False).',
)
return parser.parse_args()
def create_connection():
"""
Create a connection to oVirt engine API.
"""
# Get the path of the configuration file, by default use
# 'ovirt.ini' file in script directory:
default_path = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
'ovirt.ini',
)
config_path = os.environ.get('OVIRT_INI_PATH', default_path)
# Create parser and add ovirt section if it doesn't exist:
config = configparser.SafeConfigParser(
defaults={
'ovirt_url': os.environ.get('OVIRT_URL'),
'ovirt_username': os.environ.get('OVIRT_USERNAME'),
'ovirt_password': os.environ.get('OVIRT_PASSWORD'),
'ovirt_ca_file': os.environ.get('OVIRT_CAFILE', ''),
}
)
if not config.has_section('ovirt'):
config.add_section('ovirt')
config.read(config_path)
# Create a connection with options defined in ini file:
return sdk.Connection(
url=config.get('ovirt', 'ovirt_url'),
username=config.get('ovirt', 'ovirt_username'),
password=config.get('ovirt', 'ovirt_password', raw=True),
ca_file=config.get('ovirt', 'ovirt_ca_file') or None,
insecure=not config.get('ovirt', 'ovirt_ca_file'),
)
def get_dict_of_struct(connection, vm):
"""
Transform SDK Vm Struct type to Python dictionary.
"""
if vm is None:
return dict()
vms_service = connection.system_service().vms_service()
clusters_service = connection.system_service().clusters_service()
vm_service = vms_service.vm_service(vm.id)
devices = vm_service.reported_devices_service().list()
tags = vm_service.tags_service().list()
stats = vm_service.statistics_service().list()
labels = vm_service.affinity_labels_service().list()
groups = clusters_service.cluster_service(
vm.cluster.id
).affinity_groups_service().list()
return {
'id': vm.id,
'name': vm.name,
'host': connection.follow_link(vm.host).name if vm.host else None,
'cluster': connection.follow_link(vm.cluster).name,
'status': str(vm.status),
'description': vm.description,
'fqdn': vm.fqdn,
'os_type': vm.os.type,
'template': connection.follow_link(vm.template).name,
'tags': [tag.name for tag in tags],
'affinity_labels': [label.name for label in labels],
'affinity_groups': [
group.name for group in groups
if vm.name in [vm.name for vm in connection.follow_link(group.vms)]
],
'statistics': dict(
(stat.name, stat.values[0].datum) for stat in stats if stat.values
),
'devices': dict(
(device.name, [ip.address for ip in device.ips]) for device in devices if device.ips
),
'ansible_host': next((device.ips[0].address for device in devices if device.ips), None)
}
def get_data(connection, vm_name=None):
"""
Obtain data of `vm_name` if specified, otherwise obtain data of all vms.
"""
vms_service = connection.system_service().vms_service()
clusters_service = connection.system_service().clusters_service()
if vm_name:
vm = vms_service.list(search='name=%s' % vm_name) or [None]
data = get_dict_of_struct(
connection=connection,
vm=vm[0],
)
else:
vms = dict()
data = defaultdict(list)
for vm in vms_service.list():
name = vm.name
vm_service = vms_service.vm_service(vm.id)
cluster_service = clusters_service.cluster_service(vm.cluster.id)
# Add vm to vms dict:
vms[name] = get_dict_of_struct(connection, vm)
# Add vm to cluster group:
cluster_name = connection.follow_link(vm.cluster).name
data['cluster_%s' % cluster_name].append(name)
# Add vm to tag group:
tags_service = vm_service.tags_service()
for tag in tags_service.list():
data['tag_%s' % tag.name].append(name)
# Add vm to status group:
data['status_%s' % vm.status].append(name)
# Add vm to affinity group:
for group in cluster_service.affinity_groups_service().list():
if vm.name in [
v.name for v in connection.follow_link(group.vms)
]:
data['affinity_group_%s' % group.name].append(vm.name)
# Add vm to affinity label group:
affinity_labels_service = vm_service.affinity_labels_service()
for label in affinity_labels_service.list():
data['affinity_label_%s' % label.name].append(name)
data["_meta"] = {
'hostvars': vms,
}
return data
def main():
args = parse_args()
connection = create_connection()
print(
json.dumps(
obj=get_data(
connection=connection,
vm_name=args.host,
),
sort_keys=args.pretty,
indent=args.pretty * 2,
)
)
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,3 @@
skip_list:
- '405'
- '204'

3
roles/ansible-role-nodejs/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*.retry
*/__pycache__
*.pyc

View File

@@ -0,0 +1,34 @@
---
language: python
services: docker
env:
global:
- ROLE_NAME: nodejs
matrix:
- MOLECULE_DISTRO: centos7
- MOLECULE_DISTRO: centos6
- MOLECULE_DISTRO: ubuntu1804
- MOLECULE_DISTRO: ubuntu1604
- MOLECULE_DISTRO: debian9
- MOLECULE_DISTRO: debian8
- MOLECULE_DISTRO: centos7
MOLECULE_PLAYBOOK: playbook-latest.yml
install:
# Install test dependencies.
- pip install molecule docker
before_script:
# Use actual Ansible Galaxy role name for the project directory.
- cd ../
- mv ansible-role-$ROLE_NAME geerlingguy.$ROLE_NAME
- cd geerlingguy.$ROLE_NAME
script:
# Run tests.
- molecule test
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2017 Jeff Geerling
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,73 @@
# Ansible Role: Node.js
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-nodejs.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-nodejs)
Installs Node.js on RHEL/CentOS or Debian/Ubuntu.
## Requirements
None.
## Role Variables
Available variables are listed below, along with default values (see `defaults/main.yml`):
nodejs_version: "8.x"
The Node.js version to install. "8.x" is the default and works on most supported OSes. Other versions such as "0.12", "4.x", "5.x", "6.x", "8.x", "10.x" etc. should work on the latest versions of Debian/Ubuntu and RHEL/CentOS.
nodejs_install_npm_user: "{{ ansible_ssh_user }}"
The user for whom the npm packages will be installed can be set here, this defaults to `ansible_user`.
npm_config_prefix: "/usr/local/lib/npm"
The global installation directory. This should be writeable by the `nodejs_install_npm_user`.
npm_config_unsafe_perm: "false"
Set to true to suppress the UID/GID switching when running package scripts. If set explicitly to false, then installing as a non-root user will fail.
nodejs_npm_global_packages: []
A list of npm packages with a `name` and (optional) `version` to be installed globally. For example:
nodejs_npm_global_packages:
# Install a specific version of a package.
- name: jslint
version: 0.9.3
# Install the latest stable release of a package.
- name: node-sass
# This shorthand syntax also works (same as previous example).
- node-sass
<!-- code block separator -->
nodejs_package_json_path: ""
Set a path pointing to a particular `package.json` (e.g. `"/var/www/app/package.json"`). This will install all of the defined packages globally using Ansible's `npm` module.
## Dependencies
None.
## Example Playbook
- hosts: utility
vars_files:
- vars/main.yml
roles:
- geerlingguy.nodejs
*Inside `vars/main.yml`*:
nodejs_npm_global_packages:
- name: jslint
- name: node-sass
## License
MIT / BSD
## Author Information
This role was created in 2014 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).

View File

@@ -0,0 +1,27 @@
---
# Set the version of Node.js to install ("6.x", "8.x", "10.x", "11.x", etc.).
# Version numbers from Nodesource: https://github.com/nodesource/distributions
nodejs_version: "10.x"
# The user for whom the npm packages will be installed.
# nodejs_install_npm_user: username
# The directory for global installations.
npm_config_prefix: "/usr/local/lib/npm"
# Set to true to suppress the UID/GID switching when running package scripts. If
# set explicitly to false, then installing as a non-root user will fail.
npm_config_unsafe_perm: "false"
# Define a list of global packages to be installed with NPM.
nodejs_npm_global_packages: []
# # Install a specific version of a package.
# - name: jslint
# version: 0.9.3
# # Install the latest stable release of a package.
# - name: node-sass
# # This shorthand syntax also works (same as previous example).
# - node-sass
# The path of a package.json file used to install packages globally.
nodejs_package_json_path: ""

View File

@@ -0,0 +1,2 @@
install_date: Mon Dec 23 15:19:20 2019
version: halkeye-patch-1

View File

@@ -0,0 +1,30 @@
---
dependencies: []
galaxy_info:
author: geerlingguy
description: Node.js installation for Linux
company: "Midwestern Mac, LLC"
license: "license (BSD, MIT)"
min_ansible_version: 2.4
platforms:
- name: EL
versions:
- 6
- 7
- name: Debian
versions:
- all
- name: Ubuntu
versions:
- trusty
- xenial
- bionic
galaxy_tags:
- development
- web
- javascript
- js
- node
- npm
- nodejs

View File

@@ -0,0 +1,29 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
options:
config-file: molecule/default/yaml-lint.yml
platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
provisioner:
name: ansible
lint:
name: ansible-lint
playbooks:
converge: ${MOLECULE_PLAYBOOK:-playbook.yml}
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8

View File

@@ -0,0 +1,23 @@
---
- name: Converge
hosts: all
become: true
vars:
nodejs_version: "11.x"
nodejs_install_npm_user: root
npm_config_prefix: /root/.npm-global
npm_config_unsafe_perm: "true"
nodejs_npm_global_packages:
- node-sass
- name: jslint
version: 0.12.0
- name: yo
pre_tasks:
- name: Update apt cache.
apt: update_cache=true cache_valid_time=600
when: ansible_os_family == 'Debian'
roles:
- role: geerlingguy.nodejs

View File

@@ -0,0 +1,22 @@
---
- name: Converge
hosts: all
become: true
vars:
nodejs_install_npm_user: root
npm_config_prefix: /root/.npm-global
npm_config_unsafe_perm: "true"
nodejs_npm_global_packages:
- node-sass
- name: jslint
version: 0.12.0
- name: yo
pre_tasks:
- name: Update apt cache.
apt: update_cache=true cache_valid_time=600
when: ansible_os_family == 'Debian'
roles:
- role: geerlingguy.nodejs

View File

@@ -0,0 +1,14 @@
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_hosts_file(host):
f = host.file('/etc/hosts')
assert f.exists
assert f.user == 'root'
assert f.group == 'root'

View File

@@ -0,0 +1,6 @@
---
extends: default
rules:
line-length:
max: 220
level: warning

View File

@@ -0,0 +1,42 @@
---
- import_tasks: setup-RedHat.yml
when: ansible_os_family == 'RedHat'
- import_tasks: setup-Debian.yml
when: ansible_os_family == 'Debian'
- name: Define nodejs_install_npm_user
set_fact:
nodejs_install_npm_user: "{{ ansible_user | default(lookup('env', 'USER')) }}"
when: nodejs_install_npm_user is not defined
- name: Create npm global directory
file:
path: "{{ npm_config_prefix }}"
owner: "{{ nodejs_install_npm_user }}"
group: "{{ nodejs_install_npm_user }}"
state: directory
- name: Add npm_config_prefix bin directory to global $PATH.
template:
src: npm.sh.j2
dest: /etc/profile.d/npm.sh
mode: 0644
- name: Ensure npm global packages are installed.
npm:
name: "{{ item.name | default(item) }}"
version: "{{ item.version | default('latest') }}"
global: true
state: latest
environment:
NPM_CONFIG_PREFIX: "{{ npm_config_prefix }}"
NODE_PATH: "{{ npm_config_prefix }}/lib/node_modules"
NPM_CONFIG_UNSAFE_PERM: "{{ npm_config_unsafe_perm }}"
with_items: "{{ nodejs_npm_global_packages }}"
tags: ['skip_ansible_lint']
- name: Install packages defined in a given package.json.
npm:
path: "{{ nodejs_package_json_path }}"
when: nodejs_package_json_path is defined and nodejs_package_json_path

View File

@@ -0,0 +1,25 @@
---
- name: Ensure apt-transport-https is installed.
apt: name=apt-transport-https state=present
- name: Add Nodesource apt key.
apt_key:
url: https://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0x1655A0AB68576280
id: "68576280"
state: present
- name: Add NodeSource repositories for Node.js.
apt_repository:
repo: "{{ item }}"
state: present
with_items:
- "deb https://deb.nodesource.com/node_{{ nodejs_version }} {{ ansible_distribution_release }} main"
- "deb-src https://deb.nodesource.com/node_{{ nodejs_version }} {{ ansible_distribution_release }} main"
register: node_repo
- name: Update apt cache if repo was added.
apt: update_cache=yes
when: node_repo.changed
- name: Ensure Node.js and npm are installed.
apt: "name=nodejs={{ nodejs_version|regex_replace('x', '') }}* state=present"

View File

@@ -0,0 +1,37 @@
---
- name: Set up the Nodesource RPM directory for Node.js > 0.10.
set_fact:
nodejs_rhel_rpm_dir: "pub_{{ nodejs_version }}"
when: nodejs_version != '0.10'
- name: Set up the Nodesource RPM variable for Node.js == 0.10.
set_fact:
nodejs_rhel_rpm_dir: "pub"
when: nodejs_version == '0.10'
- name: Import Nodesource RPM key (CentOS < 7).
rpm_key:
key: http://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL
state: present
when: ansible_distribution_major_version|int < 7
- name: Import Nodesource RPM key (CentOS 7+)..
rpm_key:
key: https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL
state: present
when: ansible_distribution_major_version|int >= 7
- name: Add Nodesource repositories for Node.js (CentOS < 7).
yum:
name: "http://rpm.nodesource.com/{{ nodejs_rhel_rpm_dir }}/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version }}-1.noarch.rpm"
state: present
when: ansible_distribution_major_version|int < 7
- name: Add Nodesource repositories for Node.js (CentOS 7+).
yum:
name: "https://rpm.nodesource.com/{{ nodejs_rhel_rpm_dir }}/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version }}-1.noarch.rpm"
state: present
when: ansible_distribution_major_version|int >= 7
- name: Ensure Node.js and npm are installed.
yum: "name=nodejs state=present enablerepo='nodesource'"

View File

@@ -0,0 +1,3 @@
export PATH={{ npm_config_prefix }}/bin:$PATH
export NPM_CONFIG_PREFIX={{ npm_config_prefix }}
export NODE_PATH=$NODE_PATH:{{ npm_config_prefix }}/lib/node_modules

3
roles/geerlingguy.java/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*.retry
*/__pycache__
*.pyc

View File

@@ -0,0 +1,33 @@
---
language: python
services: docker
env:
global:
- ROLE_NAME: java
matrix:
- MOLECULE_DISTRO: centos8
- MOLECULE_DISTRO: centos7
- MOLECULE_DISTRO: centos6
- MOLECULE_DISTRO: fedora31
- MOLECULE_DISTRO: ubuntu1804
- MOLECULE_DISTRO: ubuntu1604
- MOLECULE_DISTRO: debian10
- MOLECULE_DISTRO: debian9
install:
# Install test dependencies.
- pip install molecule docker
before_script:
# Use actual Ansible Galaxy role name for the project directory.
- cd ../
- mv ansible-role-$ROLE_NAME geerlingguy.$ROLE_NAME
- cd geerlingguy.$ROLE_NAME
script:
# Run tests.
- molecule test
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2017 Jeff Geerling
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,67 @@
# Ansible Role: Java
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-java.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-java)
Installs Java for RedHat/CentOS and Debian/Ubuntu linux servers.
## Requirements
None.
## Role Variables
Available variables are listed below, along with default values:
# The defaults provided by this role are specific to each distribution.
java_packages:
- java-1.8.0-openjdk
Set the version/development kit of Java to install, along with any other necessary Java packages. Some other options include are included in the distribution-specific files in this role's 'defaults' folder.
java_home: ""
If set, the role will set the global environment variable `JAVA_HOME` to this value.
## Dependencies
None.
## Example Playbook (using default package)
- hosts: servers
roles:
- role: geerlingguy.java
become: yes
## Example Playbook (install OpenJDK 8)
For RHEL / CentOS:
- hosts: server
roles:
- role: geerlingguy.java
when: "ansible_os_family == 'RedHat'"
java_packages:
- java-1.8.0-openjdk
For Ubuntu < 16.04:
- hosts: server
tasks:
- name: installing repo for Java 8 in Ubuntu
apt_repository: repo='ppa:openjdk-r/ppa'
- hosts: server
roles:
- role: geerlingguy.java
when: "ansible_os_family == 'Debian'"
java_packages:
- openjdk-8-jdk
## License
MIT / BSD
## Author Information
This role was created in 2014 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).

View File

@@ -0,0 +1,6 @@
---
# Set java_packages if you would like to use a different version than the
# default for the OS (see defaults per OS in `vars` directory).
# java_packages: []
java_home: ""

View File

@@ -0,0 +1,2 @@
install_date: Mon Dec 23 15:19:20 2019
version: 1.9.7

View File

@@ -0,0 +1,42 @@
---
dependencies: []
galaxy_info:
role_name: java
author: geerlingguy
description: Java for Linux
company: "Midwestern Mac, LLC"
license: "license (BSD, MIT)"
min_ansible_version: 2.4
platforms:
- name: EL
versions:
- 6
- 7
- 8
- name: Fedora
versions:
- all
- name: Debian
versions:
- wheezy
- jessie
- stretch
- buster
- name: Ubuntu
versions:
- precise
- trusty
- xenial
- bionic
- name: FreeBSD
versions:
- 10.2
galaxy_tags:
- development
- system
- web
- java
- jdk
- openjdk
- oracle

View File

@@ -0,0 +1,29 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
options:
config-file: molecule/default/yaml-lint.yml
platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
provisioner:
name: ansible
lint:
name: ansible-lint
playbooks:
converge: ${MOLECULE_PLAYBOOK:-playbook.yml}
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8

View File

@@ -0,0 +1,13 @@
---
- name: Converge
hosts: all
become: true
pre_tasks:
- name: Update apt cache.
apt: update_cache=true cache_valid_time=600
when: ansible_os_family == 'Debian'
changed_when: false
roles:
- role: geerlingguy.java

View File

@@ -0,0 +1,6 @@
---
extends: default
rules:
line-length:
max: 120
level: warning

View File

@@ -0,0 +1,41 @@
---
- name: Include OS-specific variables for Fedora or FreeBSD.
include_vars: "{{ ansible_distribution }}.yml"
when: ansible_distribution == 'FreeBSD' or ansible_distribution == 'Fedora'
- name: Include version-specific variables for CentOS/RHEL.
include_vars: "RedHat-{{ ansible_distribution_version.split('.')[0] }}.yml"
when: ansible_distribution == 'CentOS' or
ansible_distribution == 'Red Hat Enterprise Linux' or
ansible_distribution == 'RedHat'
- name: Include version-specific variables for Ubuntu.
include_vars: "{{ ansible_distribution }}-{{ ansible_distribution_version.split('.')[0] }}.yml"
when: ansible_distribution == 'Ubuntu'
- name: Include version-specific variables for Debian.
include_vars: "{{ ansible_distribution|title }}-{{ ansible_distribution_version.split('.')[0] }}.yml"
when: ansible_os_family == 'Debian'
- name: Define java_packages.
set_fact:
java_packages: "{{ __java_packages | list }}"
when: java_packages is not defined
# Setup/install tasks.
- include_tasks: setup-RedHat.yml
when: ansible_os_family == 'RedHat'
- include_tasks: setup-Debian.yml
when: ansible_os_family == 'Debian'
- include_tasks: setup-FreeBSD.yml
when: ansible_os_family == 'FreeBSD'
# Environment setup.
- name: Set JAVA_HOME if configured.
template:
src: java_home.sh.j2
dest: /etc/profile.d/java_home.sh
mode: 0644
when: java_home is defined and java_home

View File

@@ -0,0 +1,16 @@
---
# See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863199 and
# https://github.com/geerlingguy/ansible-role-java/issues/64
- name: Ensure 'man' directory exists.
file:
path: /usr/share/man/man1
state: directory
recurse: true
when:
- ansible_distribution == 'Ubuntu'
- ansible_distribution_version == '18.04'
- name: Ensure Java is installed.
apt:
name: "{{ java_packages }}"
state: present

View File

@@ -0,0 +1,11 @@
---
- name: Ensure Java is installed.
pkgng:
name: "{{ java_packages }}"
state: present
- name: ensure proc is mounted
mount: name=/proc fstype=procfs src=proc opts=rw state=mounted
- name: ensure fdesc is mounted
mount: name=/dev/fd fstype=fdescfs src=fdesc opts=rw state=mounted

View File

@@ -0,0 +1,5 @@
---
- name: Ensure Java is installed.
package:
name: "{{ java_packages }}"
state: present

View File

@@ -0,0 +1 @@
export JAVA_HOME={{ java_home }}

View File

@@ -0,0 +1,6 @@
---
# JDK version options include:
# - java
# - openjdk-11-jdk
__java_packages:
- openjdk-11-jdk

View File

@@ -0,0 +1,7 @@
---
# JDK version options include:
# - java
# - openjdk-6-jdk
# - openjdk-7-jdk
__java_packages:
- openjdk-7-jdk

View File

@@ -0,0 +1,6 @@
---
# JDK version options include:
# - java
# - openjdk-8-jdk
__java_packages:
- openjdk-8-jdk

View File

@@ -0,0 +1,6 @@
---
# JDK version options include:
# - java
# - java-1.8.0-openjdk
__java_packages:
- java-1.8.0-openjdk

View File

@@ -0,0 +1,7 @@
---
# JDK version options for FreeBSD include:
# - openjdk
# - openjdk6
# - openjdk8
__java_packages:
- openjdk

View File

@@ -0,0 +1,7 @@
---
# JDK version options include:
# - java
# - java-1.6.0-openjdk
# - java-1.7.0-openjdk
__java_packages:
- java-1.7.0-openjdk

View File

@@ -0,0 +1,8 @@
---
# JDK version options include:
# - java
# - java-1.6.0-openjdk
# - java-1.7.0-openjdk
# - java-1.8.0-openjdk
__java_packages:
- java-1.8.0-openjdk

View File

@@ -0,0 +1,7 @@
---
# JDK version options include:
# - java-1.8.0-openjdk
# - java-11-openjdk
# - java-latest-openjdk
__java_packages:
- java-11-openjdk

View File

@@ -0,0 +1,7 @@
---
# JDK version options include:
# - java
# - openjdk-6-jdk
# - openjdk-7-jdk
__java_packages:
- openjdk-7-jdk

View File

@@ -0,0 +1,7 @@
---
# JDK version options include:
# - java
# - openjdk-6-jdk
# - openjdk-7-jdk
__java_packages:
- openjdk-7-jdk

View File

@@ -0,0 +1,7 @@
---
# JDK version options include:
# - java
# - openjdk-8-jdk
# - openjdk-9-jdk
__java_packages:
- openjdk-8-jdk

View File

@@ -0,0 +1,6 @@
---
# JDK version options include:
# - java
# - openjdk-11-jdk
__java_packages:
- openjdk-11-jdk

View File

@@ -1,5 +1,17 @@
---
# tasks file for sage905.mineos
- name: Ensure extra repos are enabled
rhsm_repository:
name:
- "rhel-*-optional-rpms"
- "rhel-*-extras-rpms"
state: enabled
- name: Ensure EPEL is available
yum:
name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
state: present
- name: Install Development Tools
become: true
yum: name="@Development tools" state=present

View File

@@ -12,7 +12,7 @@
# tasks:
# - name: Get first nfs server
# set_fact: ks_nfs_server="{{ groups['nfs-server'][0] }}"
# set_fact: ks_nfs_server="{{ groups['nfs_server'][0] }}"
# - set_fact: ks_file="{{ hostvars[ks_nfs_server]['nfs_dir'] }}/{{ inventory_hostname }}.cfg"
# - name: Copy ks file to builddir

View File

@@ -23,7 +23,7 @@
- toallab.infrastructure
- name: Ansible Red Demo Environment
hosts: ansible-red
hosts: ansible_red
become: false
roles:
- lightbulb-ansiblered-deck