Skip to content
Open
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
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
sudo: required
language: python
services:
- docker
before_install:
- sudo apt-get -qq update
- pip install -r requirements.txt
script:
- molecule test
13 changes: 13 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
extends: default

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
line-length: disable
# NOTE(retr0h): Templates no longer fail this lint rule.
# Uncomment if running old Molecule templates.
# truthy: disable
58 changes: 58 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# CONTRIBUTING

## Overview

Contributions are welcome!

* Please make sure that existing tests pass, and new coverage is added where changes happen.

## Local workflow

### Setup

1. Install [pyenv]
1. Set up pyenv:

```bash
pyenv install 2.7.15
pyenv install 3.7.1
pyenv global 2.7.15 3.7.1
python -m pip install virtualenv
unset PYTHONPATH
```

1. Set up virtualenv:

```bash
python -m virtualenv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
```

### Iterate

1. Fork the repository via github.
1. Clone it, add `upstream` remote.

```bash
git clone [email protected]:{you}/ansible-buildkite-agent.git
cd ansible-buildkite-agent
git checkout devel
git remote add upstream [email protected]:azavea/ansible-buildkite-agent.git
```

1. Make a new branch. `git checkout -b {branch name}`.
1. Make some changes, covered by tests. `git commit -m "some message"`.
1. Run the tests via `molecule test`.
1. Push the changes to your github fork. `git push -u origin {branch name}`
1. Open a pull-request via github (should be a hyperlink inside the git push output to click on).

#### Once you're done

Leave the virtualenv:

```bash
deactivate
```

[pyenv]: https://github.com/pyenv/pyenv#installation
10 changes: 5 additions & 5 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ buildkite_agent_tags_from_gcp: "false"
buildkite_agent_tags_from_host: "false"

# Debian options
buildkite_agent_allow_latest: yes
buildkite_agent_version: "3.7.0"
buildkite_agent_build_number: "2659"
buildkite_agent_allow_latest: true
buildkite_agent_version: "3.8.2"
buildkite_agent_build_number: "2742"

# Windows options
buildkite_agent_nssm_version: "2.24.101.20180116"
buildkite_agent_platform: "amd64"
buildkite_agent_windows_grant_admin: False
buildkite_agent_windows_grant_admin: false

# Darwin options
buildkite_agent_load_bash_profile: yes
buildkite_agent_load_bash_profile: true
2 changes: 1 addition & 1 deletion examples/site.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- hosts: all
become: True
become: true

pre_tasks:
- name: Update APT cache
Expand Down
14 changes: 14 additions & 0 deletions molecule/default/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Molecule managed

{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}

RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
16 changes: 16 additions & 0 deletions molecule/default/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*******
Docker driver installation guide
*******

Requirements
============

* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html)
* Docker Engine
* docker-py
* docker

Install
=======

$ sudo pip install docker-py
28 changes: 28 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: instance
image: solita/ubuntu-systemd:latest
privileged: true
command: /sbin/init
capabilities:
- SYS_ADMIN
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
provisioner:
name: ansible
options:
vvv: true
lint:
name: ansible-lint
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8
7 changes: 7 additions & 0 deletions molecule/default/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Converge
hosts: all
become: true

roles:
- role: ansible-buildkite-agent
10 changes: 10 additions & 0 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Prepare
hosts: all
become: true

tasks:
- name: install apt-transport-https
apt:
pkg: apt-transport-https
state: present
14 changes: 14 additions & 0 deletions molecule/default/tests/test_default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os

import testinfra.utils.ansible_runner

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


def test_hosts_file(host):
f = host.file('/etc/hosts')

assert f.exists
assert f.user == 'root'
assert f.group == 'root'
Binary file added molecule/default/tests/test_default.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ansible==2.7.5
molecule==2.19.0
docker==3.6.0
2 changes: 1 addition & 1 deletion tasks/install-on-Darwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- homebrew:
name: buildkite-agent
state: latest
update_homebrew: yes
update_homebrew: true

- name: Configure Buildkite
template:
Expand Down
17 changes: 11 additions & 6 deletions tasks/install-on-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@

# because: we run the template unit
- name: Turn off the installed service
service:
name: buildkite-agent
enabled: no
systemd:
name: buildkite-agent.service
daemon_reload: true
enabled: false
state: stopped

- name: "Create buildkite-agent service instances"
systemd: name=buildkite-agent@{{item}} state=started enabled=yes
with_sequence: start=1 end={{buildkite_agent_count}} stride=1
- name: create buildkite-agent service instances
systemd:
name: buildkite-agent@{{ item }}.service
daemon_reload: true
state: started
enabled: true
with_sequence: start=1 end={{ buildkite_agent_count }} stride=1
6 changes: 3 additions & 3 deletions tasks/install-on-Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
name: "buildkite-agent"
# TODO: Single static file with no isolation between runs is unsafe (but that's unlikely to occur)
password: "{{ user_password }}"
password_never_expires: yes
user_cannot_change_password: yes
password_never_expires: true
user_cannot_change_password: true

- name: grant administrator privileges to user
win_group_membership:
Expand Down Expand Up @@ -41,7 +41,7 @@
src: 'c:/windows/temp/buildkite-agent-windows-{{ buildkite_agent_platform }}-{{ buildkite_agent_version }}.zip'
dest: 'c:/program files/buildkite-agent'
creates: 'c:/program files/buildkite-agent/buildkite-agent.exe'
delete_archive: yes
delete_archive: true

- name: delete the shipped configuration stub to avoid binary picking it up (buildkite/agent#881)
win_file:
Expand Down