Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: add more tests #13

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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: 2 additions & 23 deletions molecule/default/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,8 @@
- theo_url: https://theo.example.com
- theo_client_token: zdOPNza4jjtceH5F2rU0iOkIJ2xlV4hGUauKT4cNe8HAp+AMnzYEzSc0EIBGM+MJuqL7gLd6bwIP
pre_tasks:
- name: Update apt cache
apt:
update_cache: yes
cache_valid_time: 600
when: ansible_os_family == 'Debian'

- name: Ensure sshd is installed
package:
name:
- openssh-server
state: present

- name: Ensure sshd service is started
service:
name: ssh
state: started
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '14.04'

- name: Ensure sshd service is started
service:
name: sshd
state: started
when: not (ansible_distribution == 'Ubuntu' and ansible_distribution_version == '14.04')
- name: Import common tasks
import_tasks: ../resources/playbooks/pre-tasks.yml

roles:
- role: ansible-theo-agent
9 changes: 8 additions & 1 deletion molecule/default/tests/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ def test_theo_config_file(host):
assert line in conf


def test_theo_cache_dir(host):
f = host.file('/var/cache/theo-agent')
assert f.exists
assert f.user == 'theo-agent'
assert f.group == 'root'


def test_sshd_config(host):
distro = os.getenv('MOLECULE_DISTRO', 'centos7')
if distro == 'centos6':
Expand All @@ -63,7 +70,7 @@ def test_sshd_config(host):
if line not in configlines:
errors.append(line)

if(len(errors)):
if len(errors):
print('Failed test_sshd_config, missing line(s)')
for error in errors:
print(error)
Expand Down
24 changes: 24 additions & 0 deletions molecule/resources/playbooks/pre-tasks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
- name: Update apt cache
apt:
update_cache: yes
cache_valid_time: 600
when: ansible_os_family == 'Debian'

- name: Ensure sshd is installed
package:
name:
- openssh-server
state: present

- name: Ensure sshd service is started

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it would be better to make it parametrized per distro/codename?
aloo 14.04 is really dead.

service:
name: ssh
state: started
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '14.04'

- name: Ensure sshd service is started
service:
name: sshd
state: started
when: not (ansible_distribution == 'Ubuntu' and ansible_distribution_version == '14.04')
14 changes: 0 additions & 14 deletions molecule/signature/Dockerfile.j2

This file was deleted.

22 changes: 0 additions & 22 deletions molecule/signature/INSTALL.rst

This file was deleted.

24 changes: 2 additions & 22 deletions molecule/signature/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,9 @@
JK85kX7Atut+tgWgwuwT5vcCAwEAAQ==
-----END PUBLIC KEY-----
pre_tasks:
- name: Update apt cache
apt:
update_cache: yes
cache_valid_time: 600
when: ansible_os_family == 'Debian'
- name: Import common tasks
import_tasks: ../resources/playbooks/pre-tasks.yml

- name: Ensure sshd is installed
package:
name:
- openssh-server
state: present

- name: Ensure sshd service is started
service:
name: ssh
state: started
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '14.04'

- name: Ensure sshd service is started
service:
name: sshd
state: started
when: not (ansible_distribution == 'Ubuntu' and ansible_distribution_version == '14.04')

roles:
- role: ansible-theo-agent