1. yum安装的jenkins修改配置文件调用ansible vim /etc/sysconfig/jenkins 2. 安装Jenkins Ansible插件 Manage Jenkins--->Manage Plugins搜索Ansible 配置Ansible Manage Jenkins--->Global Tool Configuration
3. 新建一个自由风格ansible Ad-Hoc 选择Invoke Ansible Ad-Hoc Command
4. 查看运行结果
5. 使用ansible-playbook mkdir -pv /etc/ansible/roles/tomcat/{tasks,files,templates,vars,meta,default,handlers} echo "Mlxg2234" > ./tomcat/files/a.txt 编写task tasks/main.yml - name: copy a.txt copy: src=a.txt dest=/usr/local/apache-tomcat-8.5.43/webapps/abc/ - name: shutdown tomcat shell: kill -9 `ps -ef | grep tomcat-8.5.43 | grep -v grep | awk '{print $2}'` 或者sh /usr/local/apache-tomcat-8.5.43/bin/shutdown.sh - name: startup tomcat shell: sh /usr/local/apache-tomcat-8.5.43/bin/startup.sh 在roles下编写site.yml vim site.yml - name: tomcat remote_user: root hosts: all roles: - tomcat