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

python installation aborted_advanced installation_updating a(6)

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

Ansible的参数使用key-value键值对的形式,在远程受管机器上运行一个任务,返回一个关于任务结果的JSON。这种形式可以让模块知道什么时候去做什么,键值对可以是硬编码的或者像在playbook中使用变量(第二章中将介绍)。从模块返回的数据让Ansible知道什么东西改变了、变量是否需要重新设置以及改变配置。模块通常被串在playbook中,这意味这你可以同时使用好几个模块。之前的列子中,ping模块只是检查了一下到远程受管机器的连接状态,实际上没有进行任何操作。python installation aborted

稍微更有用的一个模块叫setup,它连接远程主机,收集关于系统的数据,返回他们的值。在命令行中使用它 并不是很方便,但在之后的playbook中我们可以很好的利用这个模块的返回值。在命令行运行模块,需要指定2件事,虽然通常要指定3件,第一个是 host模块,你需要指定你希望模块应用的主机、组、~、全局、all、一个表达式匹配的主机、组、组;第二个是模块的名称和参数;

下面的命令在一个主机上运行模块:

$ ansible machinename -u root -k -m setup

setup模块会连接到远程受管机器,然后返回一些有用的数据。所有返回的数据都以ansible_为前缀。下面的表格是一些常用的值。

?

These variables are gathered using Python from the host system; if you have facter
or ohai installed on the remote node, the setup module will execute them and return
their data as well. As with other facts, ohai facts are prepended with ohai_ and
facter facts with facter_ . While the setup module doesn't appear to be too useful on
the command line, once you start writing playbooks, it will come into its own.
If all the modules in Ansible do as little as the setup and the ping module, we
will not be able to change anything on the remote machine. Almost all of the
other modules that Ansible provides, such as the file module, allow us to actually
configure the remote machine.
The file module can be called with a single path argument; this will cause it to return
information about the file in question. If you give it more arguments, it will try and
alter the file's attributes and tell you if it has changed anything. Ansible modules
will almost always tell you if they have changed anything, which becomes more
important when you are writing playbooks.
You can call the file module, as shown in the following command, to see details
about /etc/fstab :
$ ansible machinename -u root -k -m file -a 'path=/etc/fstab' 
The preceding command should elicit a response like the following code:
machinename | success >> {
"changed": false,
"group": "root",
"mode": "0644",
"owner": "root",
"path": "/etc/fstab",
"size": 779,
"state":
"file"
}
Or like the following command to create a new test directory in /tmp :
$ ansible machinename -u root -k -m file -a 'path=/tmp/test
state=directory mode=0700 owner=root'
The preceding command should return something like the following code:
machinename | success >> {
"changed": true,
"group": "root",
"mode": "0700",
"owner": "root",
"path": "/tmp/test",
"size": 4096,
"state": "directory"
}
The second command will have the changed variable set to true , if the directory
doesn't exist or has different attributes. When run a second time, the value of
changed should be false indicating that no changes were required.
There are several modules that accept similar arguments to the file module, and one
such example is the copy module. The copy module takes a file on the controller
machine, copies it to the managed machine, and sets the attributes as required. For
example, to copy the /etc/fstab file to /tmp on the managed machine, you will use
the following command:
$ ansible machinename -m copy -a 'path=/tmp/fstab mode=0700 owner=root'
The preceding command, when run the first time, should return something like the
following code:
machinename | success >> {
"changed": true,
"dest": "/tmp/fstab",
"group": "root",
"md5sum": "fe9304aa7b683f58609ec7d3ee9eea2f",
"mode": "0700",
"owner": "root",
"size": 637,
"src": "/root/.ansible/tmp/ansible-1374060150.96-
77605185106940/source",
"state": "file"
}
这些数据是python从主机系统收集而来,如果你有facter或者 ohai安装在远程受管主机上,setup模块也会运行他们并返回结果。然而,在命令行中使用setup模块的意义并不大,在使用playbooks后,它会自动执行setup模块。如果其他的模块也像ping和setup一样,那我们也无法利用Ansible做任何有意义的事情了。事实上,Ansible的其他模块,比如file模块,它可以让我们实际的改变远程受管主机的配置。


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

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

    • 杨太尉
      杨太尉

      几个男人娶一个老婆显然不是谢教授要表达的真实内容

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