Skip to content

Commit

Permalink
OPS-2691 Add support for multiple yaml documents in single template (#3)
Browse files Browse the repository at this point in the history
* OPS-2691 use from_yaml_all to process multiple yaml documents

* OPS-2691 change image links
  • Loading branch information
snovikov committed Apr 22, 2021
1 parent e450b2b commit 8a6a6cc
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:

env:
global:
- ANSIBLE_VERSION=2.5
- ANSIBLE_VERSION=2.7


jobs:
Expand All @@ -27,23 +27,23 @@ jobs:
### Stage 2: Run Ansible
###

# Job 1: Ansible 2.5
# Job 1: Ansible 2.7
- stage: test ansible
install:
- max=100; i=0; while [ $i -lt $max ]; do if sudo apt-get update; then break; else i=$((i+1)); fi done
- max=100; i=0; while [ $i -lt $max ]; do if sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce; then break; else i=$((i+1)); fi done
env:
- ANSIBLE_VERSION=2.5
- ANSIBLE_VERSION=2.7
script:
- make test ANSIBLE_VERSION=${ANSIBLE_VERSION}

# Job 2: Ansible 2.6
# Job 2: Ansible 2.8
- stage: test ansible
install:
- max=100; i=0; while [ $i -lt $max ]; do if sudo apt-get update; then break; else i=$((i+1)); fi done
- max=100; i=0; while [ $i -lt $max ]; do if sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce; then break; else i=$((i+1)); fi done
env:
- ANSIBLE_VERSION=2.6
- ANSIBLE_VERSION=2.8
script:
- make test ANSIBLE_VERSION=${ANSIBLE_VERSION}

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###
### Variables
###
ANSIBLE_VERSION=2.5
ANSIBLE_VERSION=2.7


###
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
This role renders an arbitrary number of [Jinja2](http://jinja.pocoo.org/) templates and deploys or removes them to/from Kubernetes cluster.


[![Build Status](https://travis-ci.org/cytopia/ansible-role-k8s.svg?branch=master)](https://travis-ci.org/cytopia/ansible-role-k8s)
[![Version](https://img.shields.io/github/tag/cytopia/ansible-role-k8s.svg)](https://github.com/cytopia/ansible-role-k8s/tags)
[![Build Status](https://travis-ci.org/Flaconi/ansible-role-k8s.svg?branch=master)](https://travis-ci.org/Flaconi/ansible-role-k8s)
[![Version](https://img.shields.io/github/tag/Flaconi/ansible-role-k8s.svg)](https://github.com/Flaconi/ansible-role-k8s/tags)


## Requirements

* Ansible 2.5
* Ansible 2.7
* [openshift](https://pypi.org/project/openshift/) Python package


Expand Down Expand Up @@ -164,5 +164,5 @@ make lint
make test
# Run integration tests with custom Ansible version
make test ANSIBLE_VERSION=2.6
make test ANSIBLE_VERSION=2.7
```
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ galaxy_info:
author: cytopia
license: MIT
description: Deploy and remove Kubernetes templates with Jinja2 templates
min_ansible_version: 2.6
min_ansible_version: 2.7
platforms:
- name: all
versions:
Expand Down
3 changes: 2 additions & 1 deletion tasks/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
k8s:
state: present
force: "{{ k8s_force | default(False) }}"
definition: "{{ lookup('template', k8s_item.template) | from_yaml }}"
definition: "{{ item }}"
# Optional auth variables
context: "{{ k8s_item.context | default(k8s_context | default(omit)) }}"
api_key: "{{ k8s_item.api_key | default(omit) }}"
Expand All @@ -19,6 +19,7 @@
host: "{{ k8s_item.host | default(omit) }}"
username: "{{ k8s_item.username | default(omit) }}"
password: "{{ k8s_item.password | default(omit) }}"
loop: "{{ lookup('template', k8s_item.template) | from_yaml_all | list }}"
# Alway run when k8s_tag is not defined
# or only run templates that match k8s_tag values
when: |
Expand Down
3 changes: 2 additions & 1 deletion tasks/remove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{%- endif %}ensure template is removed: {{ k8s_item.template }}
k8s:
state: absent
definition: "{{ lookup('template', k8s_item.template) | from_yaml }}"
definition: "{{ item }}"
# Optional auth variables
context: "{{ k8s_item.context | default(k8s_context | default(omit)) }}"
api_key: "{{ k8s_item.api_key | default(omit) }}"
Expand All @@ -18,6 +18,7 @@
host: "{{ k8s_item.host | default(omit) }}"
username: "{{ k8s_item.username | default(omit) }}"
password: "{{ k8s_item.password | default(omit) }}"
loop: "{{ lookup('template', k8s_item.template) | from_yaml_all | list }}"
# Alway run when k8s_tag is not defined
# or only run templates that match k8s_tag values
when: |
Expand Down

0 comments on commit 8a6a6cc

Please sign in to comment.