无法使用处理程序重新启动,
- hosts: all
remote_user: ec2-user
become: yes
vars:
ports: 1024
tasks:
- name: Add repository
yum_repository:
name: jenkins
description: jenkins
baseurl: http://pkg.jenkins.io/redhat-stable
gpgkey: https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
- name: install jenkins and java
yum:
name: "{{ item }}"
state: present
loop:
- jenkins
- java-17-amazon-corretto-jmods.x86_64
- name: changing jenkins port number
lineinfile:
path: /usr/lib/systemd/system/jenkins.service
regexp: '^Environment="JENKINS_PORT=8080"'
line: Environment="JENKINS_PORT={{ports}}
notify: restart jenkins
- name: daemon-reload to pick up config changes
systemd:
daemon_reload: yes
- name: jenkins stop
service:
name: jenkins
state: stopped
- name: start jenkins
service:
name: jenkins
state: started
handlers:
- name: restart jenkins
service:
name: jenkins
state: restarted