Merge pull request #15561 from resmo/test/support-debian

tests: make tests work for Debian 8/Ubuntu 16.04
This commit is contained in:
René Moser 2016-05-04 07:23:46 +02:00
commit fbec9ce58b
7 changed files with 34 additions and 14 deletions

View file

@ -52,15 +52,15 @@
loop_var: postgresql_package_item
when: ansible_pkg_mgr == 'apt'
- name: Initialize postgres (systemd)
- name: Initialize postgres (RedHat systemd)
command: postgresql-setup initdb
when: ansible_distribution == "Fedora" or (ansible_os_family == "RedHat" and ansible_distribution_major_version|int >= 7)
- name: Initialize postgres (sysv)
- name: Initialize postgres (RedHat sysv)
command: /sbin/service postgresql initdb
when: ansible_os_family == "RedHat" and ansible_distribution_major_version|int <= 6
- name: Iniitalize postgres (upstart)
- name: Iniitalize postgres (Debian)
command: /usr/bin/pg_createcluster {{ pg_ver }} main
# Sometimes package install creates the db cluster, sometimes this step is needed
ignore_errors: True

View file

@ -0,0 +1,10 @@
postgresql_service: "postgresql"
postgresql_packages:
- "postgresql"
- "postgresql-common"
- "python-psycopg2"
pg_hba_location: "/etc/postgresql/9.4/main/pg_hba.conf"
pg_dir: "/var/lib/postgresql/9.4/main"
pg_ver: 9.4

View file

@ -0,0 +1,10 @@
postgresql_service: "postgresql"
postgresql_packages:
- "postgresql"
- "postgresql-common"
- "python-psycopg2"
pg_hba_location: "/etc/postgresql/9.5/main/pg_hba.conf"
pg_dir: "/var/lib/postgresql/9.5/main"
pg_ver: 9.5

View file

@ -21,7 +21,7 @@
register: apt_result
- name: check hello with dpkg
shell: dpkg --get-selections | fgrep hello
shell: dpkg-query -l hello
failed_when: False
register: dpkg_result
@ -47,7 +47,7 @@
register: apt_result
- name: check hello with dpkg
shell: dpkg --get-selections | fgrep hello
shell: dpkg-query -l hello
failed_when: False
register: dpkg_result
@ -89,7 +89,7 @@
register: apt_result
- name: check hello with wildcard with dpkg
shell: dpkg --get-selections | fgrep hello
shell: dpkg-query -l hello
failed_when: False
register: dpkg_result
@ -103,10 +103,10 @@
- "dpkg_result.rc == 0"
- name: check hello version
shell: dpkg -s hello | grep Version | sed -r 's/Version:\s+([a-zA-Z0-9.-]+)\s*$/\1/'
shell: dpkg -s hello | grep Version | awk '{print $2}'
register: hello_version
- name: check hello architecture
shell: dpkg -s hello | grep Architecture | sed -r 's/Architecture:\s+([a-zA-Z0-9.-]+)\s*$/\1/'
shell: dpkg -s hello | grep Architecture | awk '{print $2}'
register: hello_architecture
- name: uninstall hello with apt

View file

@ -17,5 +17,5 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- include: 'apt.yml'
when: ansible_distribution in ('Ubuntu', 'Debian')
when: ansible_distribution in ('Ubuntu') and ansible_distribution_version|version_compare('16.04', '<')

View file

@ -13,7 +13,7 @@
- include: 'sysv_setup.yml'
when: ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and (ansible_distribution_version|version_compare('6', '>=') and ansible_distribution_version|version_compare('7', '<'))
- include: 'systemd_setup.yml'
when: (ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and (ansible_distribution_version|version_compare('7', '>=') and ansible_distribution_version|version_compare('8', '<'))) or ansible_distribution == 'Fedora' or (ansible_distribution == 'Ubuntu' and ansible_distribution_version|version_compare('15.04', '>='))
when: (ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and (ansible_distribution_version|version_compare('7', '>=') and ansible_distribution_version|version_compare('8', '<'))) or ansible_distribution == 'Fedora' or (ansible_distribution == 'Ubuntu' and ansible_distribution_version|version_compare('15.04', '>=')) or (ansible_distribution == 'Debian' and ansible_distribution_version|version_compare('8', '>='))
- include: 'upstart_setup.yml'
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version|version_compare('15.04', '<')

View file

@ -1,18 +1,18 @@
- name: install the systemd unit file
copy: src=ansible.systemd dest=/usr/lib/systemd/system/ansible_test.service
copy: src=ansible.systemd dest=/etc/systemd/system/ansible_test.service
register: install_systemd_result
- name: install a broken systemd unit file
file: src=ansible_test.service path=/usr/lib/systemd/system/ansible_test_broken.service state=link
file: src=ansible_test.service path=/etc/systemd/system/ansible_test_broken.service state=link
register: install_broken_systemd_result
- name: assert that the systemd unit file was installed
assert:
that:
- "install_systemd_result.dest == '/usr/lib/systemd/system/ansible_test.service'"
- "install_systemd_result.dest == '/etc/systemd/system/ansible_test.service'"
- "install_systemd_result.state == 'file'"
- "install_systemd_result.mode == '0644'"
- "install_systemd_result.checksum == 'ca4b413fdf3cb2002f51893b9e42d2e449ec5afb'"
- "install_broken_systemd_result.dest == '/usr/lib/systemd/system/ansible_test_broken.service'"
- "install_broken_systemd_result.dest == '/etc/systemd/system/ansible_test_broken.service'"
- "install_broken_systemd_result.state == 'link'"