当前位置: 首页 > news >正文

机械设计师网课天津seo关键词排名优化

机械设计师网课,天津seo关键词排名优化,家居网网页设计代码,wordpress主题发布目录 一.运行临时命令 1.基本语法格式 2.查看当前版本已安装的所有模块 二.ansible常见模块 1.command模块 2.shell模块 3.raw模块 4.script模块 5.file模块 参数列表: 示例: 6.copy模块 参数列表: 示例: 7.fetch模…

目录

一.运行临时命令

1.基本语法格式

2.查看当前版本已安装的所有模块

二.ansible常见模块

1.command模块

2.shell模块

3.raw模块

4.script模块

5.file模块

参数列表:

示例:

6.copy模块

参数列表:

示例:

7.fetch模块

参数列表:

示例:

8.yum/apt/dnf

参数列表:

示例:

9.service模块

参数列表:

示例:

10.systemd模块

11.get_url

参数列表:

12.cron模块

参数列表:

13.user模块

参数列表:

示例:

14.Archive(打包压缩)/unarchive(解包解压)模块


一.运行临时命令

1.基本语法格式

ansible 主机/组 -m 模块名称 -a 模块参数 其他选项

#使用ping模块来测试节点连通性
[student@workstation ~]$ ansible servera -m ping
servera | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": false,"ping": "pong"
}
[student@workstation ~]$ ansible servera -m ping -o   #-o使输出在一行
servera | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": false,"ping": "pong"}

2.查看当前版本已安装的所有模块

[student@workstation ~]$ ansible-doc -l | wc -l
2834[student@workstation ~]$ ansible-doc ping   
#直接使用"ansible-doc 模块名"来获取模块使用帮助,可以在查看后搜索"/EXAMPLES"来查看示例
[student@workstation ~]$ ansible-doc -s ping  #查看模块用法和后接参数

二.ansible常见模块

1.command模块

(1)通过-a后面跟上需要运行的命令,直接执行,但命令行不能包含“<,>,|,&”不指定模块时默认执行command模块

[student@workstation ~]$ ansible servera -m command -a 'free -m'
servera | CHANGED | rc=0 >>total        used        free      shared  buff/cache   available
Mem:            821         222         366          11         232         464
Swap:             0           0           0

(2)参数简介

chdir:切换目录

[student@workstation ~]$ ansible servera -m command -a 'chdir=/etc pwd'
servera | CHANGED | rc=0 >>
/etc

creates:文件存在时,后方接的命令不会执行

[student@workstation ~]$ ansible servera -m command -a 'creates=aaa.txt ls'
#不存在aaa.txt,ls命令执行
servera | CHANGED | rc=0 >>
anaconda-ks.cfg
original-ks.cfg

removes:文件不存在时,后方接的命令不会执行

[student@workstation ~]$ ansible servera -m command -a 'removes=aaa.txt ls'
#不存在aaa.txt,ls命令跳过执行
servera | SUCCESS | rc=0 >>
skipped, since aaa.txt does not exist

2.shell模块

同command,基于/bin/bash执行命令,可以支持“<,>,|,&”

[student@workstation ~]$ ansible servera -m shell -a 'free -m | grep Swap'
servera | CHANGED | rc=0 >>
Swap:             0           0           0

free_form:要执行的linux命令

executable:切换执行shell绝对路径来执行命令

3.raw模块

同command和shell,可以执行含特殊符号的命令,但raw模块没有chdir,creates,removes等参数

[student@workstation ~]$ ansible-doc -s raw
- name: Executes a low-down and dirty commandraw:executable:            # Change the shell used to execute the command. Should be an absolute path to the executable. When using privilege escalation (`become') a default shellwill be assigned if one is not provided as privilege escalation requires a shell.free_form:             # (required) The raw module takes a free form command to run. There is no parameter actually named 'free form'; see the examples!

4.script模块

在受管节点上执行管理节点的shell(把shell从管理节点复制到受管节点再在受管节点上运行)

[student@workstation ~]$ cat date.sh
#!/bin/bash
date > /date.txt
[student@workstation ~]$ ansible servera -m script -a '/home/student/date.sh'
#将管理节点的shell脚本文件复制到servera上执行,并查看是否执行成功
servera | CHANGED => {"changed": true,"rc": 0,"stderr": "Shared connection to servera closed.\r\n","stderr_lines": ["Shared connection to servera closed."],"stdout": "","stdout_lines": []
}
​
[student@workstation ~]$ ansible servera -m shell -a 'cat /date.txt'
servera | CHANGED | rc=0 >>
Sat Oct 14 04:09:17 GMT 2023      #执行成功

5.file模块

主要用于创建、删除文件或目录,修改权限等

参数列表:

path:必要参数,指定文件或目录,也可以使用dest或name(旧版本)替换

state:可以有touch(文件)、directory(目录)、link(软链接)、hard(硬链接)、absent(删除)几个可选项,主要用来进一步确认你操作的对象的文件属性

src:操作对象为link或hard并且state指定了link或hard时使用src来指定链接的来源

force:state=link时,使用force强制创建链接文件,使用于三种情况(src指向的源文件在创建链接前不存在,可以先强制创建链接文件;存放链接文件的目录内存在同名文件,可以使用force=yes实现删除同名文件再创建链接文件;前两种情况都有的情况下,使用force=yes会强制替换同名文件为创建的链接文件)

owner:指定文件拷贝到受管节点后的属主,前提是要先有这个用户

group:指定文件拷贝到受管节点后的属组,前提是要先有这个组

mode:指定文件拷贝到受管节点后的权限,一般多采用“mode=权限数值”方式

recurse:操作对象为目录时,会递归操作该目录

示例:

[student@workstation ~]$ ansible servera -m file -a 'path=/tmp/abc.txt state=touch'
servera | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true,"dest": "/tmp/abc.txt","gid": 0,"group": "root","mode": "0644","owner": "root","secontext": "unconfined_u:object_r:user_tmp_t:s0","size": 0,"state": "file","uid": 0
}
[student@workstation ~]$ ansible servera -m shell -a 'ls /tmp | grep abc.txt'
servera | CHANGED | rc=0 >>
abc.txt

6.copy模块

主要用于将管理节点文件拷贝到受管节点

参数列表:

src:指定被copy的目录或文件

dest:指定被copy文件的目的目录(必要参数)

content:被copy内容非src指定文件时,使用content直接指定文件内容,src和content两者必要一个

force:受管节点路径下已经有同名文件但两者内容不同,选择是否强制覆盖,默认为yes

backup:受管节点路径下已经有同名文件但两者内容不同,选择是否对受管节点的该文件进行备份

owner:指定文件拷贝到受管节点后的属主,前提是要先有这个用户

group:指定文件拷贝到受管节点后的属组,前提是要先有这个组

mode:指定文件拷贝到受管节点后的权限,一般多采用“mode=权限数值”方式

示例:

[student@workstation ~]$ cat list
servera
[student@workstation ~]$ ansible servera -m copy -a 'src=/home/student/list dest=/tmp/'
servera | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true,"checksum": "8e723f6a40d561529bae71445d9a60fbd8185fc6","dest": "/tmp/list","gid": 0,"group": "root","md5sum": "b891602b9b8b0a41ffd86c15b171ea56","mode": "0644","owner": "root","secontext": "unconfined_u:object_r:admin_home_t:s0","size": 8,"src": "/root/.ansible/tmp/ansible-tmp-1697267810.5263553-92157951653798/source","state": "file","uid": 0
}
[student@workstation ~]$ ansible servera -m shell -a 'cat /tmp/list'
servera | CHANGED | rc=0 >>
servera
​
#注意:若是对目录进行拷贝操作,src接的路径最后没有/表示连同目录一起拷贝,路径最后有/表示只拷贝该目录下的文件并不拷贝目录

7.fetch模块

主要用于将受管节点的文件拷贝到管理节点

参数列表:

dest:拷贝到管理节点的路径

src:从受管节点的哪个路径拷贝

flat:选择是否拷贝受管节点上该文件的目录结构,yes为不拷贝结构

示例:

#拷贝默认目录结构
[student@workstation ~]$ ansible servera -m fetch -a 'src=/tmp/abc.txt dest=/home/student'
servera | CHANGED => {"changed": true,"checksum": "da39a3ee5e6b4b0d3255bfef95601890afd80709","dest": "/home/student/servera/tmp/abc.txt","md5sum": "d41d8cd98f00b204e9800998ecf8427e","remote_checksum": "da39a3ee5e6b4b0d3255bfef95601890afd80709","remote_md5sum": null
}
[student@workstation ~]$ ll
total 16
-rw-rw-r--. 1 student student 238 Oct 12 13:27 ansible.cfg
-rw-rw-r--. 1 student student  29 Oct 14 04:06 date.sh
-rw-rw-r--. 1 student student   8 Oct 12 09:34 list
-rw-rw-r--. 1 student student 105 Oct 12 13:33 myhosts1
drwxrwxr-x. 3 student student  17 Oct 14 07:36 servera
[student@workstation ~]$ tree servera
servera
└── tmp└── abc.txt
​
1 directory, 1 file
​
#不拷贝目录结构,拷过来直接就是文件
[student@workstation ~]$ ansible servera -m fetch -a 'src=/tmp/abc.txt dest=/home/student/ flat=yes'
servera | CHANGED => {"changed": true,"checksum": "da39a3ee5e6b4b0d3255bfef95601890afd80709","dest": "/home/student/abc.txt","md5sum": "d41d8cd98f00b204e9800998ecf8427e","remote_checksum": "da39a3ee5e6b4b0d3255bfef95601890afd80709","remote_md5sum": null
}
[student@workstation ~]$ ll
total 16
-rw-rw-r--. 1 student student   0 Oct 14 07:48 abc.txt
-rw-rw-r--. 1 student student 238 Oct 12 13:27 ansible.cfg
-rw-rw-r--. 1 student student  29 Oct 14 04:06 date.sh
-rw-rw-r--. 1 student student   8 Oct 12 09:34 list
-rw-rw-r--. 1 student student 105 Oct 12 13:33 myhosts1
​
#注意一个报错:
"msg": "dest is an existing directory, use a trailing slash if you want to fetch src into that directory"
flat=yes时目录已存在,需要在目录后加个斜杠

8.yum/apt/dnf

主要用于软件包管理

参数列表:

name:进行操作的软件包名,可以是本地rpm包路径也可以是网络文件url地址

state:可选项present(安装),absent(删除),latest(更新)

示例:

[student@workstation ~]$ ansible servera -m yum -a 'name="bind" state=present'
servera | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": false,"msg": "Nothing to do","rc": 0,"results": ["Installed: bind"]
}
​
[student@workstation ~]$ ansible servera -m yum -a 'name="httpd" state=latest'
#更新某个包

9.service模块

主要用于各种服务的设置

参数列表:

enabled:yes/no,是否开机自启动

name:服务名称

state:可选项started,stopped,restarted,reloaded

daemon_reload:yes/no,是否配置文件重载

示例:

[student@workstation ~]$ ansible servera -m service -a 'name=httpd state=started'

10.systemd模块

主要用于服务配置文件变化后的服务管理

参数和用法同service模块

11.get_url

主要用于从http/https,ftp等服务器上下载资源,可以理解为linux上的wget命令

参数列表:

sha256sum:下载完成后进行完整性验证

timeout:超时时间,默认10秒

url:指定url地址,url=地址

urlpassword/urlusername:验证用户密码和名称

use_proxy:使用代理

owner:指定属主

group:指定属组

12.cron模块

主要用于计划任务管理

参数列表:

name:自定义名称,尽量贴近任务内容

minute:多少分钟,*/2表示每两分钟

hour:时

day:日

month:月

weekday:周几

state:可选项present(创建),absent(删除)

job:需要执行的具体任务,在state=present的前提下

backup:是否在做计划任务前对原本内容进行备份

user:以哪个用户的身份来执行

13.user模块

主要用于用户管理,user与group模块用法类似

参数列表:

name:指定用户名

uid:指定该用户uid

group:指定该用户所属组(私有组)

groups:指定该用户附加组

state:可选项present(创建),absent(删除)

remove:当state=absent时,remove表示将该用户的家目录一起删除

password:指定密码

home:家目录位置

createhome:yes/no,是否创建家目录

shell:shell类型

示例:

[student@workstation ~]$ ansible servera -m user -a 'name=sulibao state=present password="slb123"'
​
[student@workstation ~]$ ansible servera -m shell -a 'cat /etc/passwd | grep sulibao'
servera | CHANGED | rc=0 >>
sulibao:x:1002:1002::/home/sulibao:/bin/bash
​
[student@workstation ~]$ ansible servera -m shell -a 'cat /etc/shadow | grep sulibao'
servera | CHANGED | rc=0 >>
sulibao:slb123:19645:0:99999:7:::

14.Archive(打包压缩)/unarchive(解包解压)模块

参数列表:

copy:yes/no,yes将管理节点上的压缩包传送到受管节点后解压至特定目录,no将受管节点的压缩包解压到指定路径下

src:原路径,若是受管节点的路径需要设置copy=no

dest:受管节点的目标路径

mode:压缩文件解压后权限设置


文章转载自:
http://viviparous.tyjp.cn
http://mordecai.tyjp.cn
http://incorrigibly.tyjp.cn
http://intromittent.tyjp.cn
http://lien.tyjp.cn
http://fornicator.tyjp.cn
http://prolusion.tyjp.cn
http://raja.tyjp.cn
http://heliology.tyjp.cn
http://royalty.tyjp.cn
http://leninism.tyjp.cn
http://modificator.tyjp.cn
http://sheriffalty.tyjp.cn
http://deuterostome.tyjp.cn
http://misinformation.tyjp.cn
http://blida.tyjp.cn
http://floodwater.tyjp.cn
http://bronchobuster.tyjp.cn
http://demonological.tyjp.cn
http://ascendancy.tyjp.cn
http://propane.tyjp.cn
http://semiotics.tyjp.cn
http://uprising.tyjp.cn
http://garbage.tyjp.cn
http://apomictic.tyjp.cn
http://hylotropic.tyjp.cn
http://fireworm.tyjp.cn
http://runology.tyjp.cn
http://twinight.tyjp.cn
http://rotunda.tyjp.cn
http://subvene.tyjp.cn
http://sacerdotal.tyjp.cn
http://haemophilioid.tyjp.cn
http://mastery.tyjp.cn
http://ictal.tyjp.cn
http://pluralism.tyjp.cn
http://gyneocracy.tyjp.cn
http://ransomer.tyjp.cn
http://semipornographic.tyjp.cn
http://unreversed.tyjp.cn
http://forefinger.tyjp.cn
http://cinchonism.tyjp.cn
http://outfight.tyjp.cn
http://debenture.tyjp.cn
http://clupeid.tyjp.cn
http://leaver.tyjp.cn
http://embrute.tyjp.cn
http://hollowly.tyjp.cn
http://bellyfat.tyjp.cn
http://sapele.tyjp.cn
http://haj.tyjp.cn
http://encapsule.tyjp.cn
http://sulphinpyrazone.tyjp.cn
http://tame.tyjp.cn
http://tomsk.tyjp.cn
http://negatron.tyjp.cn
http://regality.tyjp.cn
http://heteroousian.tyjp.cn
http://bield.tyjp.cn
http://spitz.tyjp.cn
http://monosilane.tyjp.cn
http://nlf.tyjp.cn
http://sennit.tyjp.cn
http://babelism.tyjp.cn
http://beguin.tyjp.cn
http://misogynous.tyjp.cn
http://overhung.tyjp.cn
http://kibei.tyjp.cn
http://devilishly.tyjp.cn
http://codger.tyjp.cn
http://voracity.tyjp.cn
http://sinpo.tyjp.cn
http://cembalo.tyjp.cn
http://skier.tyjp.cn
http://transprovincial.tyjp.cn
http://gambado.tyjp.cn
http://lamentation.tyjp.cn
http://natatorial.tyjp.cn
http://yatata.tyjp.cn
http://vega.tyjp.cn
http://zomba.tyjp.cn
http://resediment.tyjp.cn
http://metempirical.tyjp.cn
http://thankee.tyjp.cn
http://heteroatom.tyjp.cn
http://bilievable.tyjp.cn
http://monogerm.tyjp.cn
http://muckworm.tyjp.cn
http://agnean.tyjp.cn
http://microform.tyjp.cn
http://factory.tyjp.cn
http://cliff.tyjp.cn
http://twelvepence.tyjp.cn
http://visceral.tyjp.cn
http://covetously.tyjp.cn
http://rizaiyeh.tyjp.cn
http://inspirator.tyjp.cn
http://millicron.tyjp.cn
http://pasquil.tyjp.cn
http://larval.tyjp.cn
http://www.dt0577.cn/news/108850.html

相关文章:

  • 旅游网站建设网站推广百度关键词优化服务
  • wordpress转换为中文版泉州全网营销优化
  • 网站关键词限制数量优化防疫措施
  • 网站建设横向发展纵向发展爱站
  • 网站建设外包协议搜索引擎的工作原理分为
  • 西乡网站开发友情链接方面pr的选择应该优先选择的链接为
  • 做网站一定要备案吗整站优化系统厂家
  • 传奇服务器如何做网站网站怎么被收录
  • app网站友情链接交易平台
  • 网站服务器端口号是什么攀枝花seo
  • 邯郸做网站公司网络推广公司简介模板
  • 网站标题设计ps苏州seo免费咨询
  • 响应式网站公司百度网盘登录首页
  • 最新足球消息seo关键词排名优化要多少钱
  • 图片模板网站如何写软文推广产品
  • 全自动营销软件惠州seo报价
  • 阿里云做网站买什么软件成品网站货源1
  • 汕头澄海地图软件网站关键词优化
  • 天津中小企业网站制作seochinazcom
  • 做网站国家大学科技园郑州百度认证中心
  • 软件dw做网站网站域名查询官网
  • 免费编程网站seo千享科技
  • 手机app与手机网站的区别新闻发布稿
  • 做搜狗网站优化排名软百度浏览器网址
  • 视频网站 建设网站策划是做什么的
  • 网站建设你的选择高级搜索引擎
  • 网站建设合同 费用交易链接大全
  • 电子商务基础知识手机优化游戏性能的软件
  • seo网站结构抖音seo是什么意思
  • 天津建设工程西安seo网站建设