In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to add ansible services to the alpine image. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it.
Add step
Using ansible in alpine requires the following steps
Dockerfile
Add the above statement to 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/*
Use mirroring
Pull the image
About 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 ~] #
Use
Confirm the version
[root@occluster ~] # docker run-it-- name ansible liumiaocn/ansible sh/ # ansible-- versionansible 2.4.1.0 config file = None configured module search path = [default Dec 14 2017, 15:51:29) [GCC 6.4.0] / #
To communicate with the host (192.168.163.172) and set the ssh path in advance, you can use 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 path confirmation
/ # ssh 192.168.163.172 hostnameoccluster/ #
Ansible Action confirmation
/ # 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"} / # is how to add ansible service to alpine image. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.