用playbook安装Apache,修改端口,配置ServerName,修改主页,设置开机自启

用playbook安装Apache,修改端口,配置ServerName,修改主页,设置开机自启

[root@ansible ansible]# vim http.yml
    ---
    - hosts: cache
  remote_user: root
  tasks:
    - name: install one specific version of Apache
      yum:
        name: httpd        //安装Apache
        state: installed
    - lineinfile:
        path: /etc/httpd/conf/httpd.conf
        regexp: '^Listen '
        line: 'Listen 8080'        //修改端口为8080
    - service:
        name: httpd
        enabled: yes        //开机自启
        state: restarted
    - copy:
        src: /root/index.html        //修改主页,可以自己写个页面
        dest: /var/www/html/index.html
[root@ansible ansible]# ansible-playbook http.yml 

你可能感兴趣的:(用playbook安装Apache,修改端口,配置ServerName,修改主页,设置开机自启)