Ansible installation on Alpine 3.4. Based on williamyey/ansible. Includes support for provisioning Windows machines.
The remote system must be prepared according to the type:
windows group in hostsdocker group in hostsFrom the directory containing the Dockerfile.local:
docker build -t ansible -f Dockerfile.local .
Use the ansible --version command to perform a simple test which displays the Ansible version in the container:
$ docker run --rm -it ansible ansible --version
ansible 2.1.1.0
config file =
configured module search path = Default w/o overrides
$
A test target in Docker may be used for further provisioning tests and will be used here to test the Local Image
The Docker test target image is built using Dockerfile.sshd:
docker build -t sshd -f Dockerfile.sshd .
The test target container may then be started in detached mode:
docker run -d --name sshd -p 22 sshd
The test target is then linked (--link sshd) to a Ansible container to run a simple ping command (ansible docker -m ping) using Ansible and the docker group.
$ docker run --rm -it --link sshd ansible ansible docker -m ping
sshd | SUCCESS => {
"changed": false,
"ping": "pong"
}
$
The ansible <inventory> -m win-ping command may be used to attempt to ping the target.
$ docker run --rm -it ansible ansible windows -m win_ping
10.10.101.173 | SUCCESS => {
"changed": false,
"ping": "pong"
}
$
The raw module may be used to issue raw commands (like DIR to list the contents of the remote directory):
$ docker run --rm -it ansible ansible windows -m raw -a "CMD /C dir"
10.10.101.173 | SUCCESS | rc=0 >>
Volume in drive C is Windows 10
Volume Serial Number is 905D-2DA8
Directory of C:\Users\Administrator
08/12/2016 11:51 AM <DIR> .
08/12/2016 11:51 AM <DIR> ..
08/12/2016 11:51 AM <DIR> .ansible
08/12/2016 12:18 PM 10 .bash_history
07/16/2016 04:47 AM <DIR> Desktop
08/12/2016 11:45 AM <DIR> Documents
07/16/2016 04:47 AM <DIR> Downloads
07/16/2016 04:47 AM <DIR> Favorites
07/16/2016 04:47 AM <DIR> Links
07/16/2016 04:47 AM <DIR> Music
07/16/2016 04:47 AM <DIR> Pictures
07/16/2016 04:47 AM <DIR> Saved Games
07/16/2016 04:47 AM <DIR> Videos
1 File(s) 10 bytes
12 Dir(s) 29,668,818,944 bytes free
$
Refer to Windows Modules for a listing an description of other available modules.
Content type
Image
Digest
Size
28.8 MB
Last updated
almost 10 years ago
docker pull psharkey/ansible-alpine