1.只有承认无知,才能装下新的东西; 2.进步来自一点点滴滴的积累; 3.广博让你更优秀,而专业让你无法替代; 4.挫折和失败能够转换为一种财富。
访问量(1038800) 积分(1523) 等级(核心会员) 排名(6)
[testusero@test linux-server-modify]$ cat copy_ssh_file.yml --- - name: copy ssh file hosts: all tasks: - name: 1 | copy ssh file authorized_key: user: testuser state: present key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}" 执行playbook命令 ansible-playb
2021-12-15 08:39 1425 0
1.创建一个ansible存放路径 [root@node02 scripts]# mkdir -p /home/monitor/ansible/nginx/{conf,bin} 2.编写nginx.yml文件 [root@node02:/home/monitor]$ cat /home/monitor/ansible/nginx/bin/nginx.yml - hosts: node01 remote_user: monitor become: yes become_method: sudo vars: hello: Ansible tas
2021-11-15 15:10 1250 0
方法一 在受管服务器上将monitor加入/etc/sudoers文件,确保monitor用户可以执行sudo su - [root@node01:/root]$ cat /etc/sudoers | grep monitor monitor ALL=(ALL) ALL 2.编辑ansible所需的hosts文件信息,将受管的服务器地址192.168.56.100加入hosts文件中。 [node01] 192.168.56.100 ansible_ssh_user=monitor ansible_ssh_pa...
2021-11-15 12:00 1625 0
fstype 指定挂载文件的系统类型,必须指定 path 定义挂载到哪个目录,必须指定 src 定义挂载内容 state 挂载状态 mounted进行挂载,修改/etc/fstab信息 unmounted临时卸载,不修改/etc/fstab信息 absent永久性卸载,并修改 /etc/fstab信息 name: 永久挂载 mount: src=/dev/sdb path=/data state=mounted fstype=iso9660 1.永久挂载 [root@an...
2021-11-14 16:33 1415 0
执行任务计划 minute 分 minute= 每分钟 hour 时 special_time=hourly 每小时 day 天 month 月 weekday 周 job 计划任务的工作 name= 计算任务名称 disbaled=true 禁用某个计划任务 disabled=false 再次开启某个计划任务 state=absent 删除某个计划任务 1.设置每周1,3,5每隔1分钟告警 [root@ansible ~]# ansible mysql -m cron -a 'minute=* w...
2021-11-14 16:21 1017 0
修改hostname主机名 [root@ansible ~]# ansible mysql -m hostname -a 'name=mysql8' 192.168.56.88 | CHANGED => { "ansible_facts": { "ansible_domain": "", "ansible_fqdn": "mysql8", "ansible_hostname": "mysql8", "ansible_nodename": "mysql8", "discovered
2021-11-14 16:13 1202 0
创建或者和删除远程主机上的文件或者目录 path 指定文件 如果远程主机上没有该文件,则进行创建 state 创建类型 touch 文件 directory 目录 state=absent 删除文件或者目录 link 软连接 src=源文件名 path=目标链接文件名 hard 硬链接 src=源文件名 path=目标链接文件名 以下三个参数,既可以修改,也可以自动添加 mod:权限 可以在添加时设置特...
2021-11-14 16:07 1026 0
1.setup获取ipv4信息 [root@ansible ~]# ansible mysql -m setup -a "filter=ansible_all_ipv4_addresses" 192.168.56.88 | SUCCESS => { "ansible_facts": { "ansible_all_ipv4_addresses": [ "192.168.56.88" ], "discovered_interpreter_python": "/usr/bin/python"
2021-11-14 14:27 1084 0
管理远程主机上的服务 name=服务名 state=started开启 / stopped 停止 / reloaded 重新加载 / restarted重启 enabled=yes 开机自启 1.启动httpd服务 [root@ansible ~]# ansible mysql -m service -a 'name=httpd state=started' 192.168.56.88 | CHANGED => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin...
2021-11-14 14:07 1017 0
state:installed 安装软件包 removed 卸载软件包 disable_gpg_check=yes :取消密钥的认证 update_cache=yes 更新缓存,需要在指定安装包时使用 1.确定被控端的yum本地源或者网络源 2.安装一个httpd yum源 [root@ansible ~]# ansible mysql -m yum -a 'name=gcc state=installed' 192.168.56.88 | SUCCESS => { "ansible_facts": { ...
2021-11-14 13:56 1187 0
path:源路径,准备打包的文件 dest:打成什么格式的包,放到什么位置 mode:权限 [root@ansible tmp]# ansible mysql -m archive -a 'path=/var/log/*.log dest=/tmp/logs.tar.gz' 192.168.56.88 | CHANGED => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "archived": [ ...
2021-11-14 12:36 1251 0
copy:copy=no为源tar包从被控端解压。 copy=tes 为源tar包从主控端解压 src:源tar包路径 dest:解压到的目标位置 mode:解压后的文件权限 [root@ansible tmp]# ansible mysql -m unarchive -a 'src=/root/logs.tar.gz dest=/tmp copy=no' 192.168.56.88 | CHANGED => { "ansible_facts": { "discovered_interpreter_python"...
2021-11-14 12:29 1165 0
fetch模块 将被控端得指定文件,拉取到Ansible服务器 src: 被控端源文件 dest: 主控端目录位置 1.拉取一个/tmp/test.txt 到ansible服务器端 [root@ansible tmp]# ansible mysql -m fetch -a 'src=/tmp/test.txt dest=/tmp' 192.168.56.88 | CHANGED => { "changed": true, "checksum": "da39a3ee5e6b4b0d3255bfef95601890afd8070...
2021-11-14 11:58 1276 0
将主控端的文件复制到远程主机,只针对文件 src 源文件路径 dest 目标文件路径 content 将指定内容覆盖写入到目标主机文件中 force=no 当主控端拷贝的文件名和目标名一致,但是内容不一致,放弃拷贝 force=yes 当主控端拷贝的文件名和目标名一致,但是内容不一致,则进行覆盖 backup=yes 当主控端拷贝的文件名和目标名一致,但是内容不一致,则...
2021-11-14 11:49 1464 0
chdir=/目录 进入到指定目录 creates 文件存在 脚本不执行 removes 文件存在 脚本执行 1.执行script模块 [root@ansible ~]# cat /root/test.sh #!/bin/sh echo `hostname` [root@ansible ~]# ansible mysql -m script -a '/root/test.sh' 192.168.56.88 | CHANGED => { "changed": true, "rc": 0, "stderr": "Shared...
2021-11-14 11:09 1348 0