分享uc浏览器怎么切换淘宝账号切换淘宝账号的方法说明。
其他教程
官方文档:https://docs.Ansible.com/ansible/latest/command_guide/intro_adhoc.html

【1】帮助
ansible-doc command # 推荐使用下面这个 ansible-doc command -s登录后复制
【2】参数解释
【3】示例演示
# 上面命令表示在 web 主机上执行 ls 命令,因为使用的是 root 用户,所以默认情况下,ls 出的结果是 web 主机中 root 用户家目录中的文件列表。 ansible web -m command -a "ls"# chdir 参数表示执行命令之前,会先进入到指定的目录中,所以上面命令表示查看 web 主机上 /testdir 目录中的文件列表,返回显示有2个文件。 ansible web -m command -a "chdir=/testdir ls"# 下面命令表示 /testdir/testfile1 文件存在于远程主机中,则不执行对应命令。/testdir/testfile3 不存在,才执行”echo test”命令。 ansible web -m command -a "creates=/testdir/testfile1 echo test"# 下面命令表示 /testdir/testfile3 文件不存在于远程主机中,则不执行对应命令。/testdir/testfile1 存在,才执行”echo test”命令。 ansible web -m command -a "removes=/testdir/testfile1 echo test"登录后复制
【1】查看帮助
ansible-doc shell -s登录后复制
【2】示例演示
# -o:一行显示 # 安装httpd ansible web -m shell -a 'yum -y install httpd' -o# 查看时间 ansible web -m shell -a 'uptime' -o登录后复制
【1】查看帮助
ansible-doc script -s登录后复制
【2】参数解释
【3】示例演示
# 下面命令表示 ansible 主机中的 /testdir/testscript.sh 脚本将在 web 主机中执行,执行此脚本之前,会先进入到 web 主机中的 /opt 目录 ansible web -m script -a "chdir=/opt /testdir/testscript.sh"# 下面命令表示,web主机中的 /testdir/testfile1文件已经存在,ansible 主机中的 /testdir/testscript.sh 脚本将不会在 web 主机中执行。 ansible web -m script -a "creates=/testdir/testfile1 /testdir/testscript.sh"# 下面命令表示,web 主机中的 /testdir/testfile1 文件存在,ansible 主机中的 /testdir/testscript.sh 脚本则会在 web 主机中执行。 ansible ansible-demo3 -m script -a "removes=/testdir/testfile1 /testdir/testscript.sh"登录后复制
【1】查看帮助
ansible-doc raw -s登录后复制
【2】示例演示
ansible web -m raw -a "ifconfig eth0 |sed -n 2p |awk '{print $2}' |awk -F: '{print $2}'"登录后复制
【1】查看帮助
ansible-doc copy -s登录后复制
【2】示例演示
# -a,--args:后面接参数 ansible web -m copy -a 'src=/etc/ansible/hosts dest=/tmp/hosts owner=root group=bin mode=777'# backup=yes/no:文件存在且文件内容不一样是否备份,默认不备份 ansible web -m copy -a 'src=/etc/ansible/hosts dest=/tmp/hosts owner=root group=bin mode=777 backup=yes'登录后复制
【1】查看帮助
ansible-doc fetch -s登录后复制
【2】示例演示
# 跟copy支持的参数差不多,src:远端主机的目录,dest:主控端目录,其实真正存放的目录在:/tmp/192.168.182.129/tmp/up.sh,会按每台主机分组存放 #This `must' be a file, not a directory:只支持单个文件获取 ansible 192.168.182.129 -m fetch -a "src=/etc/fstab dest=/testdir/ansible/"登录后复制
【1】查看帮助
ansible-doc unarchive -s登录后复制
【2】参数解释
【3】示例演示
ansible 192.168.182.129 -m unarchive -a 'src=/testdir/ansible/data.tar.gz dest=/tmp/tmp/'登录后复制
【1】查看帮助
ansible-doc archive -s登录后复制
【2】示例演示
# path:主控端目录,format:压缩格式,dest:被控端目录文件' ansible 192.168.182.129 -m archive -a 'path=/tmp/ format=gz dest=/tmp/tmp/t.tar.gz'登录后复制
【1】查看帮助
ansible-doc user -s登录后复制
【2】示例演示
# 创建用户(present:默认,可以不写) ansible web -m user -a 'name=test state=present'# 删除用户(absent) ansible web -m user -a 'name=test state=absent'# 修改密码 # 步骤一、生成加密密码 echo '777777'|openssl passwd -1 -stdin# 步骤二、修改秘密 ansible web -m user -a 'name=test password="$1$Jo5FD9Jr$2QB.BuybbtR35ga4O5o8N."'# 修改shell ansible web -m user -a 'name=test shell=/sbin/noglogin append=yes'登录后复制
【1】查看帮助
ansible-doc group -s登录后复制
【2】示例演示
# 创建 ansible 192.168.182.129 -m group -a 'name=testgroup system=yes' # 删除 ansible 192.168.182.129 -m group -a 'name=testgroup state=absent'登录后复制
【1】查看帮助
ansible-doc yum -s登录后复制
【2】示例演示
# 升级所有包 ansible web -m yum -a 'name="*" state=latest'# 安装apache ansible web -m yum -a 'name="httpd" state=latest'登录后复制
【1】查看帮助
ansible-doc service -s登录后复制
【2】示例演示
ansible web -m service -a 'name=httpd state=started'ansible web -m service -a 'name=httpd state=started enabled=yes'ansible web -m service -a 'name=httpd state=stopped'ansible web -m service -a 'name=httpd state=restarted'ansible web -m service -a 'name=httpd state=started enabled=no'登录后复制
【1】查看帮助
ansible-doc file -s登录后复制
【2】示例演示
# 创建文件 ansible web -m file -a 'path=/tmp/88.txt mode=777 state=touch'# 创建目录 ansible web -m file -a 'path=/tmp/99 mode=777 state=directory'# 删除 ansible web -m file -a 'path=/tmp/99 state=absent'登录后复制
【1】查看帮助
ansible-doc setup -s登录后复制
【2】示例演示
ansible web -m setupansible web -m setup -a 'filter=ansible_all_ipv4_addresses'登录后复制
【1】查看帮助
ansible-doc cron -s登录后复制
【2】示例演示
# 创建定时任务 ansible 192.168.182.129 -m cron -a 'minute=* weekday=1,3,5,6,7 job="/usr/bin/wall FBI warning" name=warningcron'# 关闭定时任务 ansible 192.168.182.129 -m cron -a 'disabled=true job="/usr/bin/wall FBI warning" name=warningcron'# 删除定时任务 ansible 192.168.182.129 -m cron -a ' job="/usr/bin/wall FBI warning" name=warningcron state=absent'登录后复制
【1】查看帮助
ansible-doc hostname -s登录后复制
【2】示例演示
ansible 192.168.182.129 -m hostname -a 'name=192.168.182.129'登录后复制
以上就是Ansible Ad-Hoc(点对点模式)的详细内容,更多请关注楠楠科技社其它相关文章!