当前位置: 首页> 健康> 养生 > 2024年8月19日笔记

2024年8月19日笔记

时间:2025/8/26 18:05:07来源:https://blog.csdn.net/qq_68405853/article/details/141332062 浏览次数:0次

root@m0 ~]# vim test001.yml

---

-       hosts:          group01

        remote_user:    root

        tasks:

        -       name:   卸载vsftp

                yum:    name=vsftpd     state=absent

        -       name:   安装vsftpd

                yum:    name=vsftpd     state=latest

        -       name:   启动服务

                service:        name=vsftpd     state=started   enabled=yes

        -       name:   修改配置文件

                command:        sed -i '/^anonymous_enable=YES/s/YES/NO/g' /etc/vsftpd/vsftpd.conf

                notify:

                -       abcdefg

        handlers:

                -       name:   abcdefg

                        service:        name=vsftpd     state=restarted

[root@m0 ~]# ansible-playbook ./test001.yml

[root@m0 ~]# vim test002.yml

---

-       hosts:          group01

        remote_user:    root

        tasks:

        -       name:   将管理机的rope文件复制到被控制主机

                copy:    src=/etc/yum.repos.d    dest=/etc/

                                                        

        -       name:   安装httpd

                yum:    name=httpd   state=present

                      

        -       name:   修改配置文件

                command:        sed -i '/^Listen/s/80/8080/g' /etc/httpd/conf/httpd.conf

                

        -       name:  修改默认的资源文件

                command:        echo "xxxxxxx" > /var/www/html/index.html

        

        -       name:   启动httpd服务

                service:        name=httpd   state=started

[root@m0 ~]# ansible-playbook ./test002.yml

[root@m0 ~]# vim /etc/ansible/hosts

s1 ansible_ssh_host=192.168.1.68 ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_pass=q

s2 ansible_ssh_host=192.168.1.69 ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_pass=q

[root@m0 ~]# vim test003.yml

---

-     hosts:         s1

      remote_user:   root

      tasks:

      -    name:   安装nfs-utils

           yum:    name=nfs-utils    state=latest

      -    name:   安装rpcbind

           yum:    name=rpcbind      state=latest

      -    name:   创建共享目录

           file:   path=/static      state=directory

      -    name:   配置文件

           shell:  echo '/static    *(ro,sync)' > /etc/exports

      -    name:        启动服务nfs

           service:     name=nfs          state=started   enabled=yes

      -    name:        启动服务rpdbind   

           service:     name=rpcbind      state=started   enabled=yes

-     hosts:           s2

      remote_user:     root

      tasks:

      -         name:    安装nfs-utils

                yum:     name=nfs-utils   state=latest

      -         name:     创建挂载目录

                file:     path=/nfs       state=directory

      -         name:     挂载nfs文件

                command:      mount -t nfs 192.168.1.68:/static /nfs

[root@m0 ~]# ansible-playbook ./test003.yml

关键字:2024年8月19日笔记

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: