b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

python installation aborted_advanced installation_updating a(9)

电脑杂谈  发布时间:2017-05-28 00:07:45  来源:网络整理

Ansible努力去保护不要被那些未定义的请求所改变,通过这个特性可以让命令在多个服务器上执行的时候变得更快一些。不幸的是,Ansible无法知道你的命令所指向的内容是否改变了什么东西,为了让Ansible知道这一点,我们需要提供删除和创建这2个参数给它,当使用创建时,如果文件已经存在,那么命令将不会被执行,如果执行删除时,文件存在,那么命令将被执行。

就像下面的命令:

$ ansible machinename -m command -a 'rm -rf /tmp/testing removes=/tmp/testing'

如果文件不存在:

返回skipped

machinename | skipped

否则:

ansibletest | success | rc=0 >>

下面是我的列子:

WaitFish ~ # ansible hz17 -u root -k -m command -a "rm -fr /tmp/test/fstab removes=/tmp/test/fstab"

SSH password:

192.168.7.17 | success | rc=0 >>

当第二次执行的时候,提示跳过

WaitFish ~ # ansible hz17 -u root -m command -a "rm -fr /tmp/test/fstab removes=/tmp/test/fstab"

192.168.7.17 | skipped

我们通常会使用其他模块来替代command模块,因为其他模块提供了更多的选项,并且容易捕捉到出现的问题。比如,如果我们用file模块来执行上述任务的话,Ansible的工作就会更少,当我们把file模块的stat属性设置为absent的时候,效果就与上述command命令相等。

$ ansible machinename -m file -a 'path=/tmp/testing state=absent'

如果你希望你的命令所有命令特性都可以用的话,你可以使用shell模块,它允许那些重定向、管道符、后台等命令也可以运行。他同样支持create参数,但是不支持removes。

例子如下:

$ ansible machinename -m shell -a '/opt/fancyapp/bin/installer.sh > /var/log/fancyappinstall.log creates=/var/log/fancyappinstall.log'

Module help
Unfortunately, we don't have enough space to cover every module that is available
in Ansible; luckily though, Ansible includes a command called ansible-doc that
can retrieve help information. All the modules included with Ansible have this
data populated; however, with modules gathered from elsewhere you may find
less help. The ansible-doc command also allows you to see a list of all modules
available to you.
To get a list of all the modules that are available to you along with a short description
of each type, use the following command:
$ ansible-doc -l
To see the help file for a particular module, you supply it as the single argument to
ansible-doc . To see the help information for the file module, for example, use the
following command:
$ ansible-doc file
Summary
In this chapter, we have covered which installation type to choose, installing Ansible,
and how to build an inventory file to reflect your environment. After this, we saw
how to use Ansible modules in an ad hoc style for  tasks. Finally, we discussed
how to learn which modules are available on your system and how to use the
command line to get instructions for using a module.
In the next chapter, we will learn how to use many modules together in a playbook.
This allows you to perform more complex tasks than you could do with single
modules alone.

由于空间有限,我们无法介绍Ansible的所有模块,但是在Ansible中有个命令叫做Ansible-doc,他提供了内置模块的帮助信息,我们还可以使用-l来列出我们可以使用的模块。

$ ansible-doc -l

比如我们要查看file的帮助文档,就可以输入

$ ansible-doc file

在本章中,我们介绍了如果选择安装方式、如何安装、如何创建设备清单文件。之后,我们要学习在ad hoc模式下使用模块来完成简单的任务。最后,我们会讨论哪些模块在你的系统中可用,以及如何在命令行中得到相应的指令来使用我们的模块。


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/shouji/article-49614-9.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...