2014-03-14 17:04:25 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
test_ppa_name: 'ppa:menulibre-dev/devel'
|
|
|
|
test_ppa_spec: 'deb http://ppa.launchpad.net/menulibre-dev/devel/ubuntu {{ansible_distribution_release}} main'
|
|
|
|
test_ppa_key: 'A7AD98A1' # http://keyserver.ubuntu.com:11371/pks/lookup?search=0xD06AAF4C11DAB86DF421421EFE6B20ECA7AD98A1&op=index
|
|
|
|
|
2014-05-07 13:28:01 +00:00
|
|
|
# UNINSTALL 'python-apt'
|
|
|
|
# The `apt_repository` module has the smarts to auto-install `python-apt`. To
|
|
|
|
# test, we will first uninstall `python-apt`.
|
|
|
|
- name: check python-apt with dpkg
|
|
|
|
shell: dpkg -s python-apt
|
|
|
|
register: dpkg_result
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: uninstall python-apt with apt
|
|
|
|
apt: pkg=python-apt state=absent purge=yes
|
|
|
|
register: apt_result
|
|
|
|
when: dpkg_result|success
|
|
|
|
|
2014-03-14 17:04:25 +00:00
|
|
|
#
|
|
|
|
# TEST: apt_repository: repo=<name>
|
|
|
|
#
|
|
|
|
- include: 'cleanup.yml'
|
|
|
|
|
|
|
|
- name: 'record apt cache mtime'
|
|
|
|
stat: path='/var/cache/apt/pkgcache.bin'
|
|
|
|
register: cache_before
|
|
|
|
|
|
|
|
- name: 'name=<name> (expect: pass)'
|
|
|
|
apt_repository: repo='{{test_ppa_name}}' state=present
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- name: 'assert the apt cache did *NOT* change'
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed'
|
|
|
|
- 'result.state == "present"'
|
|
|
|
- 'result.repo == "{{test_ppa_name}}"'
|
|
|
|
|
|
|
|
- name: 'examine apt cache mtime'
|
|
|
|
stat: path='/var/cache/apt/pkgcache.bin'
|
|
|
|
register: cache_after
|
|
|
|
|
|
|
|
- name: 'assert the apt cache did change'
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- 'cache_before.stat.mtime != cache_after.stat.mtime'
|
|
|
|
|
|
|
|
- name: 'ensure ppa key is installed (expect: pass)'
|
|
|
|
apt_key: id='{{test_ppa_key}}' state=present
|
|
|
|
|
|
|
|
#
|
|
|
|
# TEST: apt_repository: repo=<name> update_cache=no
|
|
|
|
#
|
|
|
|
- include: 'cleanup.yml'
|
|
|
|
|
|
|
|
- name: 'record apt cache mtime'
|
|
|
|
stat: path='/var/cache/apt/pkgcache.bin'
|
|
|
|
register: cache_before
|
|
|
|
|
|
|
|
- name: 'name=<name> update_cache=no (expect: pass)'
|
|
|
|
apt_repository: repo='{{test_ppa_name}}' state=present update_cache=no
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed'
|
|
|
|
- 'result.state == "present"'
|
|
|
|
- 'result.repo == "{{test_ppa_name}}"'
|
|
|
|
|
|
|
|
- name: 'examine apt cache mtime'
|
|
|
|
stat: path='/var/cache/apt/pkgcache.bin'
|
|
|
|
register: cache_after
|
|
|
|
|
|
|
|
- name: 'assert the apt cache did *NOT* change'
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- 'cache_before.stat.mtime == cache_after.stat.mtime'
|
|
|
|
|
|
|
|
- name: 'ensure ppa key is installed (expect: pass)'
|
|
|
|
apt_key: id='{{test_ppa_key}}' state=present
|
|
|
|
|
|
|
|
#
|
|
|
|
# TEST: apt_repository: repo=<name> update_cache=yes
|
|
|
|
#
|
|
|
|
- include: 'cleanup.yml'
|
|
|
|
|
|
|
|
- name: 'record apt cache mtime'
|
|
|
|
stat: path='/var/cache/apt/pkgcache.bin'
|
|
|
|
register: cache_before
|
|
|
|
|
|
|
|
- name: 'name=<name> update_cache=yes (expect: pass)'
|
|
|
|
apt_repository: repo='{{test_ppa_name}}' state=present update_cache=yes
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed'
|
|
|
|
- 'result.state == "present"'
|
|
|
|
- 'result.repo == "{{test_ppa_name}}"'
|
|
|
|
|
|
|
|
- name: 'examine apt cache mtime'
|
|
|
|
stat: path='/var/cache/apt/pkgcache.bin'
|
|
|
|
register: cache_after
|
|
|
|
|
|
|
|
- name: 'assert the apt cache did change'
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- 'cache_before.stat.mtime != cache_after.stat.mtime'
|
|
|
|
|
|
|
|
- name: 'ensure ppa key is installed (expect: pass)'
|
|
|
|
apt_key: id='{{test_ppa_key}}' state=present
|
|
|
|
|
|
|
|
#
|
|
|
|
# TEST: apt_repository: repo=<spec>
|
|
|
|
#
|
|
|
|
- include: 'cleanup.yml'
|
|
|
|
|
|
|
|
- name: 'record apt cache mtime'
|
|
|
|
stat: path='/var/cache/apt/pkgcache.bin'
|
|
|
|
register: cache_before
|
|
|
|
|
|
|
|
- name: 'name=<spec> (expect: pass)'
|
|
|
|
apt_repository: repo='{{test_ppa_spec}}' state=present
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed'
|
|
|
|
- 'result.state == "present"'
|
|
|
|
- 'result.repo == "{{test_ppa_spec}}"'
|
|
|
|
|
|
|
|
- name: 'examine apt cache mtime'
|
|
|
|
stat: path='/var/cache/apt/pkgcache.bin'
|
|
|
|
register: cache_after
|
|
|
|
|
|
|
|
- name: 'assert the apt cache did change'
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- 'cache_before.stat.mtime != cache_after.stat.mtime'
|
|
|
|
|
|
|
|
# When installing a repo with the spec, the key is *NOT* added
|
|
|
|
- name: 'ensure ppa key is absent (expect: pass)'
|
|
|
|
apt_key: id='{{test_ppa_key}}' state=absent
|
|
|
|
|
|
|
|
#
|
|
|
|
# TEARDOWN
|
|
|
|
#
|
|
|
|
- include: 'cleanup.yml'
|