From 4fbdbe08f2560073a8b30801325d63f8de3cb9d6 Mon Sep 17 00:00:00 2001 From: Aaron Weitekamp Date: Wed, 8 Jul 2015 17:35:21 -0400 Subject: add RHEL7 Dockerfile This Dockerfile packages ansible and the playbook as a container image. It's a proof of concept as it makes some assumptions: - bindmounts private key ~/.ssh/id_rsa - default cmd executes the byo playbook --- Dockerfile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..7fac1f0c2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM rhel7 + +MAINTAINER Aaron Weitekamp + +RUN yum -y install http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + +# Not sure if all of these packages are necessary +# only git and ansible are known requirements +RUN yum install -y --enablerepo rhel-7-server-extras-rpms net-tools bind-utils tmux git ansible + +# Not sure if this repo is required +RUN curl -o /etc/yum.repos.d/atomic-enterprise.repo http://mirror.ops.rhcloud.com/atomic/mirror/.atomic-enterprise-early-1/atomic-enterprise.repo + +RUN git clone https://github.com/projectatomic/atomic-enterprise-training.git \ + /opt/training && \ + git clone https://github.com/projectatomic/atomic-enterprise-ansible.git \ + /opt/atomic-enterprise-ansible + +CMD ansible-playbook /opt/atomic-enterprise-ansible/playbooks/byo/config.yml + +LABEL RUN docker run -it --rm --net=host -v ~/.ssh/id_rsa:/root/.ssh/id_rsa -v /etc/ansible/hosts:/etc/ansible/hosts --name NAME -e NAME=NAME -e IMAGE=IMAGE IMAGE + -- cgit v1.2.3 From 4fc01f5d73547da931f8ab822a3709e94280d7b1 Mon Sep 17 00:00:00 2001 From: Avesh Agarwal Date: Wed, 12 Aug 2015 17:30:52 -0400 Subject: Changes to Dockerfile to make it work with openshift-ansible and also added privileged flag to allow sharing host network and host dirs. --- Dockerfile | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7fac1f0c2..7fca42b9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,15 +8,8 @@ RUN yum -y install http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.no # only git and ansible are known requirements RUN yum install -y --enablerepo rhel-7-server-extras-rpms net-tools bind-utils tmux git ansible -# Not sure if this repo is required -RUN curl -o /etc/yum.repos.d/atomic-enterprise.repo http://mirror.ops.rhcloud.com/atomic/mirror/.atomic-enterprise-early-1/atomic-enterprise.repo +RUN git clone https://github.com/openshift/openshift-ansible.git /opt/openshift-ansible -RUN git clone https://github.com/projectatomic/atomic-enterprise-training.git \ - /opt/training && \ - git clone https://github.com/projectatomic/atomic-enterprise-ansible.git \ - /opt/atomic-enterprise-ansible - -CMD ansible-playbook /opt/atomic-enterprise-ansible/playbooks/byo/config.yml - -LABEL RUN docker run -it --rm --net=host -v ~/.ssh/id_rsa:/root/.ssh/id_rsa -v /etc/ansible/hosts:/etc/ansible/hosts --name NAME -e NAME=NAME -e IMAGE=IMAGE IMAGE +CMD ansible-playbook /opt/openshift-ansible/playbooks/byo/config.yml +LABEL RUN docker run -it --rm --privileged --net=host -v ~/.ssh:/root/.ssh -v /etc/ansible/hosts:/etc/ansible/hosts --name NAME -e NAME=NAME -e IMAGE=IMAGE IMAGE -- cgit v1.2.3 From 20814f5f16800dbf7956ccf8aa16eb972aeade1c Mon Sep 17 00:00:00 2001 From: Avesh Agarwal Date: Thu, 13 Aug 2015 18:17:11 -0400 Subject: Added README_ANSIBLE.md file that contains instructions to build and run ansible in a docker container, and also modified Dockerfile to replace CMD with ENTRYPOINT to run the container as executable. --- Dockerfile | 15 --------------- README_ANSIBLE.md | 18 ++++++++++++++++++ ansible-container/Dockerfile | 15 +++++++++++++++ 3 files changed, 33 insertions(+), 15 deletions(-) delete mode 100644 Dockerfile create mode 100644 README_ANSIBLE.md create mode 100644 ansible-container/Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 7fca42b9b..000000000 --- a/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM rhel7 - -MAINTAINER Aaron Weitekamp - -RUN yum -y install http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm - -# Not sure if all of these packages are necessary -# only git and ansible are known requirements -RUN yum install -y --enablerepo rhel-7-server-extras-rpms net-tools bind-utils tmux git ansible - -RUN git clone https://github.com/openshift/openshift-ansible.git /opt/openshift-ansible - -CMD ansible-playbook /opt/openshift-ansible/playbooks/byo/config.yml - -LABEL RUN docker run -it --rm --privileged --net=host -v ~/.ssh:/root/.ssh -v /etc/ansible/hosts:/etc/ansible/hosts --name NAME -e NAME=NAME -e IMAGE=IMAGE IMAGE diff --git a/README_ANSIBLE.md b/README_ANSIBLE.md new file mode 100644 index 000000000..19e32d342 --- /dev/null +++ b/README_ANSIBLE.md @@ -0,0 +1,18 @@ +# Running ansible in a docker container +* Building ansible container: + + ```sh + git clone https://github.com/openshift/openshift-ansible.git + cd openshift-ansible/ansible-container + docker build --rm -t ansible . + ``` +* Create /etc/ansible directory on the host machine and copy inventory file (hosts) into it. +* Copy ssh public key of the host machine to master and nodes machines in the cluster. +* Running the ansible container: + + ```sh + docker run -it --rm --privileged --net=host -v ~/.ssh:/root/.ssh -v /etc/ansible:/etc/ansible ansible + ``` + + + diff --git a/ansible-container/Dockerfile b/ansible-container/Dockerfile new file mode 100644 index 000000000..477ea6712 --- /dev/null +++ b/ansible-container/Dockerfile @@ -0,0 +1,15 @@ +FROM rhel7 + +MAINTAINER Aaron Weitekamp + +RUN yum -y install http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + +# Not sure if all of these packages are necessary +# only git and ansible are known requirements +RUN yum install -y --enablerepo rhel-7-server-extras-rpms net-tools bind-utils tmux git ansible + +RUN git clone https://github.com/openshift/openshift-ansible.git /opt/openshift-ansible + +ENTRYPOINT ["/usr/bin/ansible-playbook", "/opt/openshift-ansible/playbooks/byo/config.yml"] + +LABEL RUN docker run -it --rm --privileged --net=host -v ~/.ssh:/root/.ssh -v /etc/ansible:/etc/ansible --name NAME -e NAME=NAME -e IMAGE=IMAGE IMAGE -- cgit v1.2.3 From 12db07f5e2238c728c21de3977e829ca5427b64e Mon Sep 17 00:00:00 2001 From: Avesh Agarwal Date: Fri, 14 Aug 2015 09:21:19 -0400 Subject: Renamed README_ANSIBLE to README_ANSIBLE_CONTAINER as per feedback. --- README_ANSIBLE.md | 18 ------------------ README_ANSIBLE_CONTAINER.md | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) delete mode 100644 README_ANSIBLE.md create mode 100644 README_ANSIBLE_CONTAINER.md diff --git a/README_ANSIBLE.md b/README_ANSIBLE.md deleted file mode 100644 index 19e32d342..000000000 --- a/README_ANSIBLE.md +++ /dev/null @@ -1,18 +0,0 @@ -# Running ansible in a docker container -* Building ansible container: - - ```sh - git clone https://github.com/openshift/openshift-ansible.git - cd openshift-ansible/ansible-container - docker build --rm -t ansible . - ``` -* Create /etc/ansible directory on the host machine and copy inventory file (hosts) into it. -* Copy ssh public key of the host machine to master and nodes machines in the cluster. -* Running the ansible container: - - ```sh - docker run -it --rm --privileged --net=host -v ~/.ssh:/root/.ssh -v /etc/ansible:/etc/ansible ansible - ``` - - - diff --git a/README_ANSIBLE_CONTAINER.md b/README_ANSIBLE_CONTAINER.md new file mode 100644 index 000000000..19e32d342 --- /dev/null +++ b/README_ANSIBLE_CONTAINER.md @@ -0,0 +1,18 @@ +# Running ansible in a docker container +* Building ansible container: + + ```sh + git clone https://github.com/openshift/openshift-ansible.git + cd openshift-ansible/ansible-container + docker build --rm -t ansible . + ``` +* Create /etc/ansible directory on the host machine and copy inventory file (hosts) into it. +* Copy ssh public key of the host machine to master and nodes machines in the cluster. +* Running the ansible container: + + ```sh + docker run -it --rm --privileged --net=host -v ~/.ssh:/root/.ssh -v /etc/ansible:/etc/ansible ansible + ``` + + + -- cgit v1.2.3 From 8d60535de208a961958dc17f65adbbd03a166200 Mon Sep 17 00:00:00 2001 From: Avesh Agarwal Date: Fri, 14 Aug 2015 09:22:31 -0400 Subject: Removed white spaces. --- README_ANSIBLE_CONTAINER.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README_ANSIBLE_CONTAINER.md b/README_ANSIBLE_CONTAINER.md index 19e32d342..0541aef26 100644 --- a/README_ANSIBLE_CONTAINER.md +++ b/README_ANSIBLE_CONTAINER.md @@ -1,4 +1,4 @@ -# Running ansible in a docker container +# Running ansible in a docker container * Building ansible container: ```sh @@ -13,6 +13,3 @@ ```sh docker run -it --rm --privileged --net=host -v ~/.ssh:/root/.ssh -v /etc/ansible:/etc/ansible ansible ``` - - - -- cgit v1.2.3 From 85c12d98930ae17c782e4d30bae5b1c0dfaadd4f Mon Sep 17 00:00:00 2001 From: Avesh Agarwal Date: Fri, 14 Aug 2015 15:28:42 -0400 Subject: Updated Dockerfile not to clone openshift-ansible repo. Movied Dockerfile to openshift-ansible repo root and updated README_ANSIBLE_CONTAINER.md file. --- Dockerfile | 17 +++++++++++++++++ README_ANSIBLE_CONTAINER.md | 2 +- ansible-container/Dockerfile | 15 --------------- 3 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 Dockerfile delete mode 100644 ansible-container/Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..ab16ca609 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM rhel7 + +MAINTAINER Aaron Weitekamp + +RUN yum -y install http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + +# Not sure if all of these packages are necessary +# only git and ansible are known requirements +RUN yum install -y --enablerepo rhel-7-server-extras-rpms net-tools bind-utils git ansible + +ADD ./ /opt/openshift-ansible/ + +ENTRYPOINT ["/usr/bin/ansible-playbook"] + +CMD ["/opt/openshift-ansible/playbooks/byo/config.yml"] + +LABEL RUN docker run -it --rm --privileged --net=host -v ~/.ssh:/root/.ssh -v /etc/ansible:/etc/ansible --name NAME -e NAME=NAME -e IMAGE=IMAGE IMAGE diff --git a/README_ANSIBLE_CONTAINER.md b/README_ANSIBLE_CONTAINER.md index 0541aef26..30c5f8503 100644 --- a/README_ANSIBLE_CONTAINER.md +++ b/README_ANSIBLE_CONTAINER.md @@ -3,7 +3,7 @@ ```sh git clone https://github.com/openshift/openshift-ansible.git - cd openshift-ansible/ansible-container + cd openshift-ansible docker build --rm -t ansible . ``` * Create /etc/ansible directory on the host machine and copy inventory file (hosts) into it. diff --git a/ansible-container/Dockerfile b/ansible-container/Dockerfile deleted file mode 100644 index 477ea6712..000000000 --- a/ansible-container/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM rhel7 - -MAINTAINER Aaron Weitekamp - -RUN yum -y install http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm - -# Not sure if all of these packages are necessary -# only git and ansible are known requirements -RUN yum install -y --enablerepo rhel-7-server-extras-rpms net-tools bind-utils tmux git ansible - -RUN git clone https://github.com/openshift/openshift-ansible.git /opt/openshift-ansible - -ENTRYPOINT ["/usr/bin/ansible-playbook", "/opt/openshift-ansible/playbooks/byo/config.yml"] - -LABEL RUN docker run -it --rm --privileged --net=host -v ~/.ssh:/root/.ssh -v /etc/ansible:/etc/ansible --name NAME -e NAME=NAME -e IMAGE=IMAGE IMAGE -- cgit v1.2.3