ansible 批量安装yum包

技术文章 1年前 (2021) 完美者
1,453 0

标签:key   ide   安装   bsp   into   name   ssh   install   start   


yum install ansible

2、修改一下ansible的参数以防ssh过去的时候需要首次判断yes  或者no 

sed -i s/#host_key_checking = False/host_key_checking = False/g /etc/ansible/ansible.cfg

3、新建一个工作目录,写一个hosts文件 用来配置hosts

[root@192 et]# cat hosts


- name: Install screen
  hosts: own_host
    - name: start install screen
        name: screen
        state: installed


ssh-keygen -t rsa

ssh-copy-id -i ~/.ssh/

[root@web ~]# ssh-copy-id -i ~/.ssh/
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/"
The authenticity of host ‘ (‘ can‘t be established.
ECDSA key fingerprint is SHA256:bqCO0nWIDL1xZsor1O5E819ZLoV2aE+TDOmiKNBM+sQ. ECDSA key fingerprint is MD5:21:18:a5:32:7f:9e:0e:48:41:d7:86:21:2a:36:8a:ee. 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 installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@‘s password:  Number of key(s) added: 1 Now try logging into the machine, with: "ssh ‘‘" and check to make sure that only the key(s) you wanted were added. [root@web ~]#

[root@web ~]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/ The key fingerprint is: SHA256:HC81CyaFnd4u2uxEhIg6CEISxw+XN/t4hP1vxfkbohY The keys randomart image is: +---[RSA 2048]----+ |o+. . o.. | |o.o.o.+oo | |o .+..o*=.o | |+. . o=+=.o | |+ +Soo . . | | . ..+.oE + | | =.. ..o o | | ..o .+ . o| | .. .o ..| +----[SHA256]-----+ [root@web ~]#



ansible-playbook -i /opt/et/hosts /opt/et/screen.yml

[root@web ~]# ansible-playbook -i /opt/et/hosts /opt/et/screen.yml

PLAY [Install screen] *********************************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************
ok: []

TASK [start install screen] ***************************************************************************************************************************************************************
changed: []

PLAY RECAP ********************************************************************************************************************************************************************************         : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

[root@web ~]#


ansible 批量安装yum包

标签:key   ide   安装   bsp   into   name   ssh   install   start   


版权声明:完美者 发表于 2021-01-07 12:10:47。
转载请注明:ansible 批量安装yum包 | 完美导航