sc

[defaults]
remote_user = student
ask_pass = false
inventory = /home/student/ansible/inventory
roles_path = /home/student/ansible/rolse

[privilege_escalation]
become = True
become_method = sudo
become_user = root
become_ask_pass = false
[dev]
servera

[test]
serverb

[prod]
serverc
serverd

[balancers]
serverb

[webservers:children]
prod

!/bin/bash

ansible all -m yum_repository -a ‘name=EX294_BASE description=”EX294 base software”
baseurl=http://content.example.com/rhel8.2/x86_64/dvd/BaseOS gpgcheck=yes
gpgkey=http://content.example.com/rhel8.2/x86_64/dvd/RPM-GPG-KEY-redhat-release
enabled=yes’

ansible all -m yum_repository -a ‘name=EX294_STREAM description=”EX294 stream software”
baseurl=http://content.example.com/rhel8.2/x86_64/dvd/AppStream gpgcheck=yes
gpgkey=http://content.example.com/rhel8.2/x86_64/dvd/RPM-GPG-KEY-redhat-release

enabled=yes’

  • hosts: dev,test,prod
    tasks:
  • name: install php mariadb
    yum:
    name:
    – php
    – mariadb
    state: present
  • name: install group development
    yum:
    name: “@Development Tools”
    state: present
    when: ansible_hostname in groups[“dev”]
  • name: update
    yum:
    name: “*”
    state: lastest

when: ansible_hostname in groups[“dev”]

  • name: configure install ntpsync server hosts: all vars: timesync_ntp_servers:
    • name: 172.25.254.254
      iburst: yes
      roles:
    • linux-systemsync-roles.timesync
  • name: set selinux
    hosts: all
    vars:
  • selinux_state: enforcing
  • selinux_fcontexts:
    • { target: ‘/var/www/html(/.*)?’, setype: ‘httpd_sys_content_t’, ftype: ‘d’, state: ‘present’ }
  • selinux_ports:
    • { ports: ’82’, porto: ‘tcp’, setype: ‘http_port_t’, state: ‘present’ }
  • selinux_restore_dirs:
    • /var/www/html
      roles:
    • role: rhel-system-roles.selinux

ansible-galaxy install -r /home/student/ansible/rolse/requirements.yml -p /home/student/ansible/rolse/

ansible-galaxy init apache –init-path /home/student/ansible/roles
cd /home/student/ansible/roles/apache

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注