Skip to content

Instantly share code, notes, and snippets.

@cankush625
Created March 7, 2021 18:57
Show Gist options
  • Select an option

  • Save cankush625/e51ce11eb9e641919d0482446d1035d2 to your computer and use it in GitHub Desktop.

Select an option

Save cankush625/e51ce11eb9e641919d0482446d1035d2 to your computer and use it in GitHub Desktop.
---
- hosts: localhost
tasks:
- name: Launch a new container
docker_container:
name: my-container
image: cankush625/centos-ssh:v2
state: started
detach: yes
interactive: yes
tty: yes
ports:
- "80:80"
- name: Container details
docker_container_info:
name: "my-container"
register: containerinfo
- debug:
var: containerinfo.container.NetworkSettings.IPAddress
- name: Create inventory file
template:
src: ./inventory_template
dest: /tmp/inventory/inventory_template
- hosts: docker
tasks:
- name: Install httpd
package:
name: httpd
state: present
- name: Start httpd
command: /usr/sbin/httpd
- name: Copy webpage
copy:
src: index.html
dest: /var/www/html/index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment