zoukankan      html  css  js  c++  java
  • 【ansible】密钥免密登陆使用重点

    Ansible 密钥免密登陆使用重点

    1、配置/etc/ansible/hosts  

     2、配置公钥以及秘钥 

    authorized_keys 放置公钥文件
    .ssh 放置密钥文件 密钥文件名称必须为 id_rsa 【重点】

    3、如何使用su 到root 执行命令 

    ansible all  -b --become-method su -m shell -a "ls /root" 如何su到root 

    4、拷贝文件 执行文件 

    ansible all -b  --become-method su  -m copy -a "src=/root/a.sh dest=/root/b.sh mode=0755"

    ansible all -b  --become-method su  -m shell  -a "/root/b.sh"

    或者使用 script 模块  直接执行 本地脚本

    ansible all -b --become-method su -u operater-hryt -m script -a "/root/a.sh "

    a.sh ------------------------>  筛选出所有挂载数据盘 以及系统盘使用情况 【除去 docker挂载点】

    #!/bin/bash
    ip=`ifconfig|awk 'NR==2{print $2}'`
    echo "主机IP地址为:$ip"
    a=`awk /^[^#]/'{print $2}' /etc/fstab`
    for i in $a
    do
    df -h |awk '{if($6==i) print $0}' i=$i
    done
    echo "----------------划分线-----------------"
    rm -rf /root/b.sh

  • 相关阅读:
    LDA模型了解及相关知识
    GAN
    tensorflow学习6
    GAN的文献综述
    python相关工具
    tensorflow学习5----变量管理
    tensorflow学习5----GAN模型初探
    8月14日至8月20日技术积累
    8月7日至8月13日技术积累
    8月1日到8月6日技术要点
  • 原文地址:https://www.cnblogs.com/oscarli/p/11978311.html
Copyright © 2011-2022 走看看