Skip to content

Commit af16acb

Browse files
author
Alberto Garcia Fernandez
committedNov 18, 2016
Update cache on java installation
1 parent 6b730a5 commit af16acb

File tree

7 files changed

+26
-4
lines changed

7 files changed

+26
-4
lines changed
 

‎.flake8

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
ignore = E501

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
tests/playbook.retry
22
tests/.cache
3+
tests/__pycache__
34
.molecule
45
.vagrant

‎README.md

+6
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ molecule test
2525
```
2626

2727
There is a pre_task with python2 to satisfy ubuntu vbox image dependencies
28+
29+
## Omit linter
30+
31+
[ANSIBLE0010] Line 28 tasks/main.yml Omit linter as we usually want jdk on latest version within propper version
32+
[ANSIBLE0010] Line 35 tasks/main.yml Omit linter as we usually want this package on latest versions aswell as previous one
33+
[ANSIBLE0012] Line 5 tests/playbook.yml Omit linter as we dont care about syntax on this pre_tasks. Its just to allow testing on ubuntu

‎meta/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
---
22
galaxy_info:
3-
description: Prometheus node_exporter role
3+
description: Java role, install java versions and set systems default

‎tasks/main.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
- name: Debian repo key
99
apt_repository:
1010
repo: "{{ java_repo }}"
11-
update_cache: yes
1211
when: ansible_distribution in [ 'Debian' ]
1312

1413
- name: Add Java ppa to Ubuntu
1514
apt_repository:
1615
repo: ppa:{{ java_ppa }}
17-
update_cache: yes
1816
when: ansible_distribution in [ 'Ubuntu' ]
1917

2018
- name: Autoaccept license for Java
@@ -30,13 +28,19 @@
3028
pkg: oracle-java{{ item }}-installer
3129
state: latest
3230
install_recommends: yes
31+
update_cache: yes
32+
cache_valid_time: 3600
3333
with_items: "{{ java_version }}"
34+
tags: skip_ansible_lint
3435

3536
- name: Set Java Env
3637
apt:
3738
pkg: oracle-java{{ java_set_version }}-set-default
3839
state: latest
3940
install_recommends: yes
41+
update_cache: yes
42+
cache_valid_time: 3600
43+
tags: skip_ansible_lint
4044

4145
- name: Ensure Defaults on etc/alternatives systems
4246
file:

‎tests/playbook.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
hosts: all
44
gather_facts: no
55
pre_tasks:
6-
- raw: sudo apt-get -y install python-simplejson
6+
- name: Install python2 on Ubuntu
7+
raw: sudo apt-get -y install python-simplejson
8+
changed_when: false
9+
tags: skip_ansible_lint
710

811
- hosts: all
912
roles:

‎tests/test_ansible.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import pytest
22

3+
34
@pytest.fixture()
45
def AnsibleDefaults(Ansible):
56
return Ansible("include_vars", "defaults/main.yml")["ansible_facts"]
67

8+
79
@pytest.fixture()
810
def AnsibleVars(Ansible):
911
return Ansible("include_vars", "tests/group_vars/group01.yml")["ansible_facts"]
1012

13+
1114
@pytest.fixture()
1215
def AnsibleDistribution(Ansible):
1316
return Ansible("setup")["ansible_facts"]["ansible_distribution"]
1417

18+
1519
def test_java_resources(File, AnsibleDefaults, AnsibleDistribution):
1620
if AnsibleDistribution == "Debian":
1721
java_resources = File("/etc/apt/sources.list.d/ppa_launchpad_net_webupd8team_java_ubuntu.list")
@@ -22,10 +26,12 @@ def test_java_resources(File, AnsibleDefaults, AnsibleDistribution):
2226
else:
2327
raise ValueError("Unsupported distribution: " + AnsibleDistribution)
2428

29+
2530
def test_java_package(Package, AnsibleVars):
2631
for version in AnsibleVars["java_version"]:
2732
assert Package("oracle-java" + version + "-installer").is_installed
2833

34+
2935
def test_java_default(File, Package, Command, AnsibleVars):
3036
assert Package("oracle-java" + AnsibleVars["java_set_version"] + "-set-default").is_installed
3137
assert AnsibleVars["java_set_version"] in Command("java -version").stderr

0 commit comments

Comments
 (0)
Please sign in to comment.