创建部署目录
[root@ansible ~]# mkdir install_ftp
将centos镜像文件出入
创建yum源
# 根据自己的实际情况进行编写
[root@ansible install_ftp]# cat http.repo
[centos]
name=centos
baseurl=http://192.168.33.250/centos-repo
gpgcheck=0
enabled=1
创建部署剧本
[root@ansible install_ftp]# cat install_ftp.yaml
- hosts: node1
remote_user: root
tasks:
- name: rm repo
shell: rm -rf /etc/yum.repos.d/*
- name: copy repo
copy: src=http.repo dest=/etc/yum.repos.d/
- name: install vsftpd
shell: yum install -y vsftpd
- name: set path
shell: echo 'anon_root=/opt' >> /etc/vsftpd/vsftpd.conf
- name: restart vsftpd
shell: systemctl restart vsftpd && systemctl enable vsftpd
- name: copy centos
copy: src=CentOS-7-x86_64-DVD-2009.iso dest=/root
- name: mount CentOS-7-x86_64-DVD-2009.iso
shell: mount CentOS-7-x86_64-DVD-2009.iso /mnt
- name: mkdir centos-repo
shell: mkdir -p /opt/centos-repo
- name: copy mnt
shell: cp -frv /mnt/* /opt/centos-repo
运行剧本文件
[root@ansible install_ftp]# ansible-playbook install_ftp.yaml