Sign inSign up

karatejb/ansible-control-node

By karatejb

•Updated over 5 years ago

Image
0

190

karatejb/ansible-control-node repository overview

⁠Ansible.ControlNode

The project can immediately create a docker container as Ansible⁠ control node to run Ansible playbook.

Github⁠

Docker Hub⁠

See HOW TO USE⁠ and following the steps.


⁠HOW TO USE

⁠1. PULL DOCKER IMAGE
$ docker pull karatejb/ansible-control-node:latest

For more tags, see karatejb/ansible-control-node⁠.

Before using the container to run your Ansible playbook, you have to

  • Prepare your Ansible playbook.
  • Set the SSH key on Managed node.
⁠2. Run the container
$ docker run -d -it [-v /Demo/Playbooks:/dev/ansible:rw] --name <container_name> karatejb/ansible-control-node:ubuntu1804 bash

Use volume to mounts the playbooks on your docker host into the container in order to run the playbook, it is optional.

For example,

$ docker run -d -it -v /Demo/Playbooks:/dev/ansible:rw --name my-ansible karatejb/ansible-control-node:ubuntu1804 bash

For Docker for Windows, run as following,

$ docker run -d -it -v D:\...:/dev/ansible --name ansible-control karatejb/ansible-control-node:ubuntu1804 bash
⁠3. Set SSH public key to Managed node

The container had already generated a new SSH public & private keys in ~/.ssh/.

├── id_rsa
├── id_rsa.pub
└── known_hosts

⁠3.1 Get the SSH public key

On docker host, copy the SSH pulic key from Control node, and copy the authorized_keys from Managed node.

  • Copy the SSH public key from the Ansible container
$ mkdir tmp
$ docker cp my-ansible:/root/.ssh/id_rsa.pub ./tmp/
⁠3.2 Write back to Managed node

Copy the authorized_keys from Managed node

$ scp [-P 22] root@<managed_node_ip>:~/.ssh/authorized_keys ./tmp/

Update authorized_keys with the SSH public key

$ cat tmp/id_rsa.pub >> tmp/authorized_keys

Copy back the updated authorized_keys to Managed node

$ scp [-P 22] tmp/authorized_keys root@<managed_node_ip>:~/.ssh/authorized_keys

Tag summary

Content type

Image

Digest

Size

375.9 MB

Last updated

over 5 years ago

docker pull karatejb/ansible-control-node