Skip to content

Commit

Permalink
parametrize inventory test
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Oct 9, 2020
1 parent 2c1bae3 commit bc92373
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions tests/test_playbooks/inventory_plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,30 @@
foreman_hosts:
testhost1.example.com: group_a
testhost2.example.com: group_b/group_c
foreman_version: '2.1-stable'
_foreman_container: "{{ foreman_container | default('quay.io/foreman/foreman') }}"
_foreman_version: "{{ foreman_version | default('2.1-stable') }}"
_foreman_host: "{{ foreman_host | default('foreman') }}"
_foreman_port: "{{ foreman_port | default('3000') }}"
_postgres_version: "{{ postgres_version | default('12') }}"
_postgres_host: "{{ postgres_host | default('postgres') }}"
collections:
- community.general
- theforeman.foreman
tasks:
- name: fetch PostgreSQL container
docker_image:
name: postgres:12
name: postgres:{{ _postgres_version }}
source: pull

- name: fetch Foreman container
docker_image:
name: quay.io/foreman/foreman:{{ foreman_version }}
name: "{{ _foreman_container }}:{{ _foreman_version }}"
source: pull

- name: start PostgreSQL container
docker_container:
name: postgres
image: postgres:12
name: "{{ _postgres_host }}"
image: postgres:{{ _postgres_version }}
env:
POSTGRES_USER: foreman
POSTGRES_PASSWORD: foreman
Expand All @@ -39,23 +44,23 @@

- name: start Foreman container
docker_container:
name: foreman
image: quay.io/foreman/foreman:{{ foreman_version }}
name: "{{ _foreman_host }}"
image: "{{ _foreman_container }}:{{ _foreman_version }}"
command: bash -c "bundle exec bin/rails db:create db:migrate && bundle exec bin/rails db:seed && bundle exec bin/rails server -b 0.0.0.0"
env:
SEED_ADMIN_PASSWORD: changeme
RAILS_ENV: production
DATABASE_URL: postgres://foreman:foreman@postgres/foreman?pool=5
DATABASE_URL: postgres://foreman:foreman@{{ _postgres_host }}/foreman?pool=5
links:
- postgres:postgres
- "{{ _postgres_host }}:{{ _postgres_host }}"
published_ports:
- "0.0.0.0:3000:3000"
- "0.0.0.0:{{ _foreman_port }}:3000"

- name: wait for foreman to start
status_info:
username: admin
password: changeme
server_url: http://127.0.0.1:3000/
server_url: http://127.0.0.1:{{ _foreman_port }}/
register: result
until:
- result is success
Expand All @@ -67,7 +72,7 @@
hostgroup:
username: admin
password: changeme
server_url: http://127.0.0.1:3000/
server_url: http://127.0.0.1:{{ _foreman_port }}/
name: "{{ item.name }}"
parent: "{{ item.parent | default(omit) }}"
organizations:
Expand All @@ -80,7 +85,7 @@
host:
username: admin
password: changeme
server_url: http://127.0.0.1:3000/
server_url: http://127.0.0.1:{{ _foreman_port }}/
name: "{{ item.key }}"
hostgroup: "{{ item.value }}"
build: false
Expand All @@ -96,7 +101,7 @@

- name: submit facts for hosts
uri:
url: http://127.0.0.1:3000/api/hosts/facts
url: http://127.0.0.1:{{ _foreman_port }}/api/hosts/facts
url_username: admin
url_password: changeme
validate_certs: false
Expand Down Expand Up @@ -162,5 +167,5 @@

- name: remove Foreman container
docker_container:
name: foreman
name: "{{ _foreman_host }}"
state: absent

0 comments on commit bc92373

Please sign in to comment.