System Env
Install Python36
- upgrade system pkgs
[root@ansible /]# yum clean all && yum makecache
[root@ansible /]# yum upgrade -y
- install python36
[root@ansible /]# yum install epel-release -y
[root@ansible /]# yum clean all && yum makecache
[root@ansible /]# yum install python36 python36-devel python36-pip -y
- set pip3.6 as the default pip
[root@ansible /]# pip3.6 install --upgrade pip
Install Ansible
[root@ansible /]# pip install ansible
Run it in Docker
- write a Dockerfile
[root@DockerServer /]# cat Dockerfile
FROM centos:latest
MAINTAINER Kyle Chen
ENV LANG C.UTF-8
ENV DEBIAN_FRONTEND=noninteractive
RUN yum clean all && \
yum makecache && \
yum upgrade -y && \
yum install vim openssh-server epel-release -y && \
yum clean all && \
yum makecache && \
yum install python36 python36-devel python36-pip -y && \
echo "set -o vi" >> /etc/bashrc && \
pip3.6 install --upgrade pip && \
pip install ansible && \
echo "PASSWORD" | passwd --stdin USER && \
systemctl enable sshd
- build an image
[root@DockerServer /]# docker build . -t ansible
- run image
[root@DockerServer /]# docker run --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro --ip IP --dns DNS --name ansible --hostname ansible -tdi ansible:latest /usr/sbin/init
- ATTENTION:
You must set the PASSWORD, USER, IP, DNS which can be found before you run image. After run image, you can use 'ssh USER@IP' and input password to login on the server.
Related
Be First to Comment