配置文件
--- - hosts: word tasks: - name: copy jdk copy: src=/opt/node_exporter-0.18.1.linux-amd64.tar.gz dest=/home/ - name: Decompressing files shell: chdir=/home/ tar zxf node_exporter-0.18.1.linux-amd64.tar.gz - name: service copy: src=/opt/ansible/node_exporter.service dest=/usr/lib/systemd/system/ - name: Ansible delete file example file: path: /home/node_exporter-0.18.1.linux-amd64.tar.gz state: absent - name: 开机 shell: systemctl daemon-reload - name: 开机启动 shell: systemctl enable node_exporter - name: 启动服务 shell: systemctl start node_exporter - name: 检查服务是否启动 shell: netstat -tlpn | grep 9100 register: port - debug: msg: "{{ port.stdout }}"
启动脚本
[xiaoxin@iZ2zee6df2m25shq6mfaw5Z ansible]$ cat node_exporter.service #Prometheus Node Exporter Upstart script [Unit] Description=Node Exporter Wants=network-online.target After=network-online.target [Service] ExecStart=/home/node_exporter-0.18.1.linux-amd64/node_exporter [Install] WantedBy=default.target
执行
[xiaoxin@iZ2zee6df2m25shq6mfaw5Z ansible]$ sudo ansible-playbook install_node_exporter.ymal --extra-vars "ansible_ssh_user=root"
继续阅读
- 我的QQ
- QQ扫一扫
-
- 我的头条
- 头条扫一扫
-
评论