Skip to content

Commit

Permalink
initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
hswong3i committed Feb 24, 2020
1 parent 8d73c8b commit 8fc5d95
Show file tree
Hide file tree
Showing 79 changed files with 5,942 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.log
*.orig
*.pyc
*.rej
*.retry
__pycache__
56 changes: 56 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---

os: linux

dist: bionic

language: shell

env:
jobs:
- MOLECULE_SCENARIO_NAME="centos-7"
- MOLECULE_SCENARIO_NAME="suse-15"
- MOLECULE_SCENARIO_NAME="ubuntu-18.04"
- MOLECULE_SCENARIO_NAME="ubuntu-19.10"

jobs:
allow_failures:
- env: MOLECULE_SCENARIO_NAME="centos-7"
- env: MOLECULE_SCENARIO_NAME="suse-15"

before_install:
- |
curl -Os https://releases.hashicorp.com/vagrant/2.2.7/vagrant_2.2.7_x86_64.deb
curl -Os https://releases.hashicorp.com/vagrant/2.2.7/vagrant_2.2.7_SHA256SUMS
curl -Os https://releases.hashicorp.com/vagrant/2.2.7/vagrant_2.2.7_SHA256SUMS.sig
gpg --receive-key 51852D87348FFC4C
gpg --verify vagrant_2.2.7_SHA256SUMS.sig vagrant_2.2.7_SHA256SUMS
sha256sum -c vagrant_2.2.7_SHA256SUMS 2>&1 | grep OK
sudo apt-get update && sudo apt-get install -y bridge-utils dnsmasq-base ebtables libvirt-bin libvirt-dev qemu-kvm qemu-utils ruby-dev
sudo dpkg -i vagrant_2.2.7_x86_64.deb
sudo vagrant plugin install vagrant-libvirt
- |
sudo apt-get -y purge python3-openssl && sudo apt-get -y autoremove
sudo apt-get update && sudo apt-get install -y ca-certificates curl gcc iproute2 pwgen python3 python3-dev sudo
curl -skL https://bootstrap.pypa.io/get-pip.py | sudo -H python3
sudo -H pip3 install --upgrade --ignore-installed --requirement requirements.txt
install:
- |
export ROLE=$(echo $TRAVIS_REPO_SLUG | sed 's/^.*\/ansible-role-/\//g')
mkdir -p $HOME/.ansible/roles
ln -s $TRAVIS_BUILD_DIR $HOME/.ansible/roles/$ROLE
script:
- |
source ./scripts/run-tests.sh \
&& sudo -E molecule dependency -s $MOLECULE_SCENARIO_NAME \
&& sudo -E molecule lint -s $MOLECULE_SCENARIO_NAME \
&& sudo -E molecule syntax -s $MOLECULE_SCENARIO_NAME \
&& sudo -E molecule converge -s $MOLECULE_SCENARIO_NAME \
&& travis_wait 120 sudo -E molecule idempotence -s $MOLECULE_SCENARIO_NAME \
&& sudo -E molecule verify -s $MOLECULE_SCENARIO_NAME
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
35 changes: 35 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---

extends: default

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
colons:
max-spaces-after: -1
level: error
commas:
max-spaces-after: -1
level: error
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
max: 3
level: error
hyphens:
level: error
indentation:
spaces: 2
indent-sequences: true
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: disable
new-lines:
type: unix
trailing-spaces: disable
truthy: disable
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Ansible Role for Podman

## 4.3.0 - TBC

### Major Changes

## 4.2.0 - 2020-02-24

- Ininitial release for Ansible 2.9 or higher
- Support both Ubuntu 18.04/19.10 or RHEL/CentOS 7 or openSUSE Leap 15.1
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
# ansible-role-podman
Ansible Role for Podman Installation
# Ansible Role for Podman

[![Travis](https://img.shields.io/travis/alvistack/ansible-role-podman.svg)](https://travis-ci.org/alvistack/ansible-role-podman)
[![GitHub release](https://img.shields.io/github/release/alvistack/ansible-role-podman.svg)](https://github.com/alvistack/ansible-role-podman)
[![GitHub license](https://img.shields.io/github/license/alvistack/ansible-role-podman.svg)](https://github.com/alvistack/ansible-role-podman/blob/master/LICENSE)
[![Ansible Role](https://img.shields.io/badge/galaxy-alvistack.podman-blue.svg)](https://galaxy.ansible.com/alvistack/podman)

Ansible Role for Podman Installation.

## Requirements

This role require Ansible 2.9 or higher.

This role was designed for Ubuntu 18.04/19.10 or RHEL/CentOS 7 or openSUSE Leap 15.1.

## Role Variables

[defaults/main.yml](defaults/main.yml)

## Dependencies

[meta/main.yml](meta/main.yml)

## Example Playbook

[molecule/ubuntu-18.04/playbook.yml](molecule/ubuntu-18.04/playbook.yml)

## License

- Code released under [Apache License 2.0](LICENSE)
- Docs released under [CC BY 4.0](http://creativecommons.org/licenses/by/4.0/)

## Author Information

- Wong Hoi Sing Edison
- <https://twitter.com/hswong3i>
- <https://github.com/hswong3i>
43 changes: 43 additions & 0 deletions ansible-role-requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---

# (c) Wong Hoi Sing Edison <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

- name: python
src: https://github.com/alvistack/ansible-role-python
version: develop

- name: git
src: https://github.com/alvistack/ansible-role-git
version: develop

- name: golang
src: https://github.com/alvistack/ansible-role-golang
version: develop

- name: runc
src: https://github.com/alvistack/ansible-role-runc
version: develop

- name: conmon
src: https://github.com/alvistack/ansible-role-conmon
version: develop

- name: cri_tools
src: https://github.com/alvistack/ansible-role-cri_tools
version: develop

- name: cni_plugins
src: https://github.com/alvistack/ansible-role-cni_plugins
version: develop
14 changes: 14 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[ssh_connection]
control_path = %(directory)s/%%h-%%p-%%r
pipelining = true
scp_if_ssh = true
ssh_args = -o ControlMaster=auto -o ControlPersist=600s

[defaults]
ansible_managed = Ansible managed: Do NOT edit this file manually!
display_failed_stderr = true
forks = 20
host_key_checking = false
interpreter_python = auto
nocows = 1
retry_files_enabled = false
21 changes: 21 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---

# (c) Wong Hoi Sing Edison <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Podman version.
podman_version: "v1.8.0"

# Podman download details.
podman_download: "{{ _podman_download[podman_version] }}"
15 changes: 15 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---

# (c) Wong Hoi Sing Edison <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
38 changes: 38 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---

# (c) Wong Hoi Sing Edison <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

galaxy_info:
role_name: podman
author: Wong Hoi Sing Edison <[email protected]>
description: Ansible Role for Podman Installation
company: PantaRei Design
license: Apache-2.0
min_ansible_version: 2.9
platforms:
- name: Ubuntu
versions:
- xenial
- bionic
- eoan
- name: EL
versions:
- 7
- name: opensuse
versions:
- all
galaxy_tags:
- system
dependencies: []
28 changes: 28 additions & 0 deletions molecule/centos-7/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---

# (c) Wong Hoi Sing Edison <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

- hosts: all
remote_user: root
become: true
roles:
- role: python
- role: git
- role: golang
- role: runc
- role: conmon
- role: cri_tools
- role: cni_plugins
- role: podman
59 changes: 59 additions & 0 deletions molecule/centos-7/create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
- name: Create
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}"
tasks:
- name: Create molecule instance(s)
molecule_vagrant:
instance_name: "{{ item.name }}"
instance_interfaces: "{{ item.interfaces | default(omit) }}"
instance_raw_config_args: "{{ item.instance_raw_config_args | default(omit) }}"

config_options: "{{ item.config_options | default(omit) }}"

platform_box: "{{ item.box }}"
platform_box_version: "{{ item.box_version | default(omit) }}"
platform_box_url: "{{ item.box_url | default(omit) }}"

provider_name: "{{ molecule_yml.driver.provider.name }}"
provider_memory: "{{ item.memory | default(omit) }}"
provider_cpus: "{{ item.cpus | default(omit) }}"
provider_options: "{{ item.provider_options | default(omit) }}"
provider_raw_config_args: "{{ item.provider_raw_config_args | default(omit) }}"
provider_override_args: "{{ item.provider_override_args | default(omit) }}"

provision: "{{ item.provision | default(omit) }}"

state: up
register: server
with_items: "{{ molecule_yml.platforms }}"

# NOTE(retr0h): Vagrant/VBox sucks and parallelizing instance creation
# causes issues.

# Mandatory configuration for Molecule to function.

- name: Populate instance config dict
set_fact:
instance_conf_dict: {
'instance': "{{ item.Host }}",
'address': "{{ item.HostName }}",
'user': "{{ item.User }}",
'port': "{{ item.Port }}",
'identity_file': "{{ item.IdentityFile }}", }
with_items: "{{ server.results }}"
register: instance_config_dict
when: server is changed

- name: Convert instance config dict to a list
set_fact:
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
when: server is changed

- name: Dump instance config
copy:
content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}"
dest: "{{ molecule_instance_config }}"
when: server is changed
Loading

0 comments on commit 8fc5d95

Please sign in to comment.