Skip to content

Instantly share code, notes, and snippets.

@dalethestirling
Created September 2, 2016 10:19
Show Gist options
  • Save dalethestirling/31a577b300c5fab7ee978fd7bddb7b2f to your computer and use it in GitHub Desktop.
Save dalethestirling/31a577b300c5fab7ee978fd7bddb7b2f to your computer and use it in GitHub Desktop.
Ansible Container HelloWorld

Ansible-continer HelloWorld

Here is a quick ansible-container HelloWorsld deployment running Nginx.

The config creates a single Centos 7 container running nginx exposed on port 8080.

This GIST assumes you have read the ansible-container docs and have a sucessful install of the app and its prerequisits.

Install

  1. Run ansible-container init
  2. In the ansible directory created populate container.yml and main.yml with the content below
  3. In the ansible directory creat a directory called files
  4. In the files dorectory create a file called index.html and copy the content below or your own custom HTML
  5. Run ansible-container build
  6. Run ansible-container run

You should now be able to browse to http://localhost:8080 in your local browser and see the content of files/index.html.

version: "1"
services:
web:
image: centos:7
ports:
- "8080:80"
command: ['/usr/bin/dumb-init', 'nginx', '-c', '/etc/nginx/nginx.conf', "-g", "daemon off;"]
registries: {}
<b>Hello World!</b>
- hosts: web
tasks:
- name: Install dumb init
get_url: dest=/usr/bin/dumb-init \
url=https://github.com/Yelp/dumb-init/releases/download/v1.0.2/dumb-init_1.0.2_amd64 \
mode=0775 \
validate_certs=no
- name: Install EPEL
yum: name=epel-release state=latest
- name: Install Nginx
yum: name=nginx state=latest
- name: Copy index update
copy: src=files/index.html dest=/usr/share/nginx/html/index.html owner=root group=root mode=0777
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment