commit 3bb1fb28bb45b7f4ad1ace7bcd9db56cd03a73cd Author: Gary Kwok Date: Fri Jan 26 15:43:35 2024 +0800 v1 diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..742a4c0 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,4 @@ +[defaults] +inventory = ./inventory +roles_path = ./roles +host_key_checking = False diff --git a/inventory b/inventory new file mode 100644 index 0000000..32deb7f --- /dev/null +++ b/inventory @@ -0,0 +1,9 @@ +[all] +pvgapp1 ansible_host=192.168.11.121 +pvgapp2 ansible_host=192.168.11.122 +pvgapp3 ansible_host=192.168.11.123 + +[staging] +pvgapp1 ansible_host=192.168.11.121 +pvgapp2 ansible_host=192.168.11.122 +pvgapp3 ansible_host=192.168.11.123 diff --git a/main.yml b/main.yml new file mode 100644 index 0000000..4d152c5 --- /dev/null +++ b/main.yml @@ -0,0 +1,5 @@ +--- +- name: main task + hosts: staging + roles: + - role: hello_world diff --git a/roles/hello_world/tasks/main.yml b/roles/hello_world/tasks/main.yml new file mode 100644 index 0000000..0e6dab6 --- /dev/null +++ b/roles/hello_world/tasks/main.yml @@ -0,0 +1,7 @@ +--- +- name: show remote host + debug: + msg: "the remote server is {{ ansible_host }}" +- name: show vars of this playbook + debug: + msg: "{{ greeting }}" diff --git a/roles/hello_world/vars/main.yml b/roles/hello_world/vars/main.yml new file mode 100644 index 0000000..e6e1d29 --- /dev/null +++ b/roles/hello_world/vars/main.yml @@ -0,0 +1 @@ +greeting: "hello ansible-playbook"