From 587fccac64da24aabf352fde6a213d6b68931f77 Mon Sep 17 00:00:00 2001 From: 3err0 Date: Wed, 6 Dec 2023 19:56:44 +0800 Subject: [PATCH] asible --- ansible/deploy_webctl.yml | 43 +++++++++++++++++++++++++++++++++++++++ ansible/hosts.ini | 11 ++++++++++ 2 files changed, 54 insertions(+) create mode 100644 ansible/deploy_webctl.yml create mode 100644 ansible/hosts.ini diff --git a/ansible/deploy_webctl.yml b/ansible/deploy_webctl.yml new file mode 100644 index 0000000..b1d578c --- /dev/null +++ b/ansible/deploy_webctl.yml @@ -0,0 +1,43 @@ +- name: Deploy RemoteSysManager script + hosts: all + become: yes + + vars: + script_url: "http://your_script_url/webctl" + script_path: "/usr/local/bin/webctl" + systemd_service_name: "webctl.service" + systemd_service_path: "/etc/systemd/system/{{ systemd_service_name }}" + + tasks: + - name: Download webctl script + ansible.builtin.get_url: + url: "{{ script_url }}" + dest: "{{ script_path }}" + mode: '0755' + + - name: Create systemd service file for webctl + ansible.builtin.copy: + dest: "{{ systemd_service_path }}" + content: | + [Unit] + Description=RemoteSysManager Service + After=network.target + + [Service] + Type=simple + ExecStart={{ script_path }} + Restart=on-failure + + [Install] + WantedBy=multi-user.target + mode: '0644' + + - name: Reload systemd daemon + ansible.builtin.systemd: + daemon_reload: yes + + - name: Enable and start webctl service + ansible.builtin.systemd: + name: "{{ systemd_service_name }}" + enabled: yes + state: started diff --git a/ansible/hosts.ini b/ansible/hosts.ini new file mode 100644 index 0000000..99d374b --- /dev/null +++ b/ansible/hosts.ini @@ -0,0 +1,11 @@ +[all] +server1.example.com +server2.example.com +server3.example.com + +[all:vars] +ansible_user=user +ansible_ssh_pass=pass +ansible_become=true +ansible_become_method=sudo +ansible_become_pass=pass \ No newline at end of file