Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions roles/command/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# vim: set ft=ansible:
#
# Runs a command and optionally checks stdout output
#
# Parameters:
# cmd (string) - command to run
# output (string) - optional substring to check for in stdout
# use caution as it is a substring search
#

- name: Fail if cmd is not defined
fail:
msg: "cmd is undefined"
when: cmd is undefined

- name: Run command
command: "{{ cmd }}"
register: cmd_output

- name: Verify output
fail:
msg: "{{ output }} is not in command output"
when: output is defined and
output not in cmd_output.stdout
75 changes: 75 additions & 0 deletions roles/etcd_sys_container_install/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
# vim: set ft=ansible:
#
# This role installs etcd system container and verifies installation by setting
# and retrieving the /atomic.io/network/config key/pair. It will optionally
# delete the key after
#
# Parameters:
# delete_key (boolean) - optional parameter to delete key after
# verifying the set and get of the key. This is useful since etcd
# keys are preserved even after uninstalling the system container
#

- name: Set facts
set_fact:
etcd_image: 'registry.access.redhat.com/rhel7/etcd'
etcd_name: 'etcd'
when: ansible_distribution == 'RedHat'

- name: Set facts
set_fact:
etcd_image: 'registry.fedoraproject.org/f25/etcd'
etcd_name: 'etcd'
when: ansible_distribution != 'RedHat'

- name: Install etcd
command: >
atomic install
--system
--name=etcd
{{ etcd_image }}
register: ai_etcd
retries: 5
delay: 60
until: ai_etcd|success

- name: Start etcd
command: systemctl start etcd

- name: Verify etcd is active
command: systemctl is-active etcd
register: etcd_output
failed_when: "'active' not in etcd_output.stdout"

- name: Wait for etcd port to open
wait_for:
port: 2379
timeout: 30

- name: Configure etcd
command: >
runc exec etcd etcdctl
set /atomic.io/network/config '{"Network":"172.17.0.0/16"}'
register: set_etcd

- name: Verify etcd settings
command: >
runc exec etcd etcdctl
get /atomic.io/network/config
register: get_etcd
failed_when: set_etcd.stdout != get_etcd.stdout

- name: Delete key
command: >
runc exec etcd etcdctl
rm /atomic.io/network/config
when: delete_key is defined and delete_key

- name: Verify key is deleted
command: >
runc exec etcd etcdctl
get /atomic.io/network/config
register: get_etcd
failed_when: get_etcd.rc == 0
when: delete_key is defined and delete_key
25 changes: 25 additions & 0 deletions roles/shell/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# vim: set ft=ansible:
#
# Runs a command and optionally checks stdout output
#
# Parameters:
# cmd (string) - command to run
# output (string) - optional string to check for in stdout
# use caution as it is a substring search
#

- name: Fail if cmd is not defined
fail:
msg: "cmd is undefined"
when: cmd is undefined

- name: Run command
shell: "{{ cmd }}"
register: cmd_output

- name: Verify output
fail:
msg: "{{ output }} is not in command output"
when: output is defined and
output not in cmd_output.stdout
47 changes: 47 additions & 0 deletions tests/improved-sanity-test/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@
- atomic_installation_verify
- cloud_image

# Install etcd system container
- role: etcd_sys_container_install
tags:
- etcd_sys_container_install

# Upgrade and reboot
- role: rpm_ostree_upgrade
tags:
Expand Down Expand Up @@ -389,6 +394,48 @@
tags:
- rpm_ostree_install_verify

# Check etcd system container is still running
- role: command
cmd: systemctl status etcd
output: 'active (running)'
tags:
- command

# Uninstall etcd system container
- role: atomic_system_uninstall
name: etcd
tags:
- atomic_system_uninstall

# Verify etcd system container uninstall
- role: atomic_system_uninstall_verify
image: etcd
tags:
- atomic_system_uninstall_verify

# Install etcd system container
- role: etcd_sys_container_install
delete_key: True
tags:
- etcd_sys_container_install
- cloud_image
check_mode: no

# Uninstall etcd system container
- role: atomic_system_uninstall
name: etcd
tags:
- atomic_system_uninstall
- cloud_image
check_mode: no

# Verify etcd system container uninstall
- role: atomic_system_uninstall_verify
image: etcd
tags:
- atomic_system_uninstall_verify
- cloud_image

- role: rpm_ostree_install
packages: httpd
reboot: false
Expand Down