ansible.sh: Add env variables to talk with foreman.

cm/site.yml: Install foreman.
library/roles: Basic foreman installation role.
library/roles/openjdk: Ansible 2 fixes.
This commit is contained in:
Andrea Dell'Amico 2016-03-10 20:32:04 +01:00
parent f6414fdb92
commit 1095dd936c
4 changed files with 55 additions and 9 deletions

14
foreman/defaults/main.yml Normal file
View File

@ -0,0 +1,14 @@
---
# foreman PKG state: latest, installed, absent
foreman_pkg_state: latest
foreman_repos:
- 'deb http://deb.theforeman.org/ trusty 1.10'
- 'deb http://deb.theforeman.org/ plugins 1.10'
foreman_repo_key: 'http://deb.theforeman.org/pubkey.gpg'
foreman_puppetlabs_repo_pkg: 'puppetlabs-release-{{ ansible_distribution_release }}.deb'
foreman_puppetlabs_repo_url: 'https://apt.puppetlabs.com/{{ foreman_puppetlabs_repo_pkg }}'
foreman_ansible_plugin:
- ruby-foreman-ansible

View File

@ -0,0 +1,33 @@
---
- name: Download the puppetlabs repo package
get_url: url='{{ foreman_puppetlabs_repo_url }}' dest=/srv/{{ foreman_puppetlabs_repo_pkg }}
register: puppetlabs_repo
tags: foreman
- name: Install the puppetlabs repo package
apt: deb=/srv/{{ foreman_puppetlabs_repo_pkg }} update_cache=yes
when: puppetlabs_repo | changed
tags: foreman
- name: Add the foreman repo keys
apt_key: url='{{ foreman_repo_key }}' state=present
- name: Add the foreman repos
apt_repository: repo='{{ item }}' update_cache=yes
with_items: '{{ foreman_repos }}'
tags: foreman
- name: Install the ansible foreman plugin
apt: pkg={{ item }} state={{ foreman_pkg_state }}
with_items: '{{ foreman_ansible_plugin }}'
tags: foreman
- name: Install the foreman installer
apt: pkg=foreman-installer state={{ foreman_pkg_state }}
register: foreman_installer_pkg
tags: foreman
- name: Run the foremann installer
shell: foreman-installer
when: foreman_installer_pkg | changed
tags: foreman

3
foreman/tasks/main.yml Normal file
View File

@ -0,0 +1,3 @@
---
- include: foreman-packages.yml

View File

@ -2,21 +2,17 @@
- name: Update the apt cache, if needed
apt: update_cache=yes
when: openjdk_pkg_state == 'latest'
tags:
- jdk
tags: jdk
- name: install OpenJDK JRE
apt: pkg=openjdk-{{ item.0 }}-{{ item[1] }} state={{ openjdk_pkg_state }}
with_nested:
- openjdk_version
- '{{ openjdk_version }}'
- [ 'jre', 'jre-headless', 'jdk' ]
notify:
Set the default OpenJDK
tags:
- jdk
notify: Set the default OpenJDK
tags: jdk
- name: Set fact jdk_installed
set_fact: jdk_installed=true
tags:
- jdk
tags: jdk