怎么在alpine镜像中添加ansible服务
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,本篇文章给大家分享的是有关怎么在alpine镜像中添加ansible服务,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。添加步骤在alpi
千家信息网最后更新 2025年12月02日怎么在alpine镜像中添加ansible服务
本篇文章给大家分享的是有关怎么在alpine镜像中添加ansible服务,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
添加步骤
在alpine中使用ansible需要如下几步
Dockerfile
在Dockerfile中添加上面的语句:
#update apk for installRUN apk update#install ansible and opensshRUN apk add ansible openssh#init ansible hosts fileRUN mkdir -p /etc/ansibleRUN echo "localhost" >/etc/ansible/hosts#init rsa ssh key pairRUN ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa#delete cache files RUN rm -rf /var/cache/apk/*
使用镜像
拉取镜像
大概103M左右
[root@occluster ~]# docker pull liumiaocn/ansibleUsing default tag: latestTrying to pull repository docker.io/liumiaocn/ansible ... latest: Pulling from docker.io/liumiaocn/ansibleff3a5c916c92: Already exists 42a81541f983: Pull complete 86602ac17bcb: Pull complete 73cb14e49a3f: Pull complete bdfcad59d746: Pull complete 455ffeaa5bf1: Pull complete dff32643cfa5: Pull complete Digest: sha256:46284f3d3b9e3880f9b65fa6b1fb225b19bc88222badf74aa85936aabc24090fStatus: Downloaded newer image for docker.io/liumiaocn/ansible:latest[root@occluster ~]# [root@occluster ~]# docker images |grep ansibledocker.io/liumiaocn/ansible latest 8a5cfdf8243f Less than a second ago 103 MB[root@occluster ~]#
使用
进行版本确认
[root@occluster ~]# docker run -it --name ansible liumiaocn/ansible sh/ # ansible --versionansible 2.4.1.0 config file = None configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible python version = 2.7.14 (default, Dec 14 2017, 15:51:29) [GCC 6.4.0]/ #
与宿主机(192.168.163.172)进行沟通,事先设定ssh通路,可以使用ssh-copy-id
/ # ssh-copy-id 192.168.163.172/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"The authenticity of host '192.168.163.172 (192.168.163.172)' can't be established.ECDSA key fingerprint is SHA256:uh84Xw56LhiCXb1b0uFbX/CoFhkqHGZjtmLwl3qkTOY.Are you sure you want to continue connecting (yes/no)? yes/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installedexpr: warning: '^ERROR: ': using '^' as the first characterof a basic regular expression is not portable; it is ignored/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keysroot@192.168.163.172's password: Number of key(s) added: 1Now try logging into the machine, with: "ssh '192.168.163.172'"and check to make sure that only the key(s) you wanted were added./ #
ssh通路确认
/ # ssh 192.168.163.172 hostnameoccluster/ #
ansible动作确认
/ # echo "192.168.163.172" >>/etc/ansible/hosts/ # ansible 192.168.163.172 -m ping192.168.163.172 | SUCCESS => { "changed": false, "failed": false, "ping": "pong"}/ #以上就是怎么在alpine镜像中添加ansible服务,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注行业资讯频道。
镜像
服务
更多
知识
篇文章
实用
动作
宿主
宿主机
就是
工作会
文章
步骤
版本
看吧
知识点
行业
详情
语句
资讯
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
智能网络安全特点
中国网络安全竞争力排行
南通比较大的软件开发
邯郸霆源软件开发有限公司
密码法网络安全宣传片
网络安全秘诀
内存数据库王珊
云南网络安全知识竞答答案
成都凸起科技互联网
运满满网络安全审查还要多久
戴尔服务器在国内哪里生产
巴拿马抗攻击服务器
网络安全防护怎么关闭手机
好心情网络技术有限公司
通达oa服务器断电
手机服务器错误504
计算机网络技术中专书
静态网络安全编程网页
服务器异常 管理员联系
硕士数据库
db2数据库删除
濮阳软件开发联系熊掌网络
鸿峥网络技术
服务器填充
常州运营软件开发优势
怎么查询服务器有几个op
服务器回收公司在线咨询
耒阳软件开发专业学校
沈阳高性能服务器
锐捷网络软件开发内推