diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg new file mode 100644 index 0000000..732abdf --- /dev/null +++ b/ansible/ansible.cfg @@ -0,0 +1,10 @@ +[defaults] +inventory = ./inventory +remote_user = ubuntu +private_key_file = ~/.ssh/id_rsa +host_key_checking = False +retry_files_enabled = False +ansible_python_interpreter = /usr/local/bin/python3.10 + +[inventory] +#enable_plugins = script diff --git a/ansible/clone.yml b/ansible/clone.yml new file mode 100644 index 0000000..a5f1ff1 --- /dev/null +++ b/ansible/clone.yml @@ -0,0 +1,8 @@ +--- +- name: Clone + hosts: app + tasks: + - name: Clone repo + git: + repo: https://github.com/express42/reddit.git + dest: /home/ubuntu/reddit diff --git a/ansible/inventory b/ansible/inventory new file mode 100644 index 0000000..c83595a --- /dev/null +++ b/ansible/inventory @@ -0,0 +1,6 @@ +#ppserver ansible_python_interpreter=/usr/local/bin/python3.10 +#dbserver ansible_python_interpreter=/usr/local/bin/python3.10 +[app] +appserver ansible_host=158.160.113.162 +[db] +dbserver ansible_host=51.250.71.145 diff --git a/ansible/inventory.json b/ansible/inventory.json new file mode 100644 index 0000000..35813ad --- /dev/null +++ b/ansible/inventory.json @@ -0,0 +1,34 @@ +#!/bin/bash + +server1ip=$(yc compute instances list | awk '{print $10}' | sed '/^[[:space:]]*$/d' | sed '1d' | head -1) +server1host=$(yc compute instances list | awk '{print $4}' | sed '/^[[:space:]]*$/d' | sed '1d' | head -1| tr - _) +server2ip=$(yc compute instances list | awk '{print $10}' | sed '/^[[:space:]]*$/d' | sed '1d' | tail -1) +server2host=$(yc compute instances list | awk '{print $4}' | sed '/^[[:space:]]*$/d' | sed '1d' | tail -1| tr - _) + + +if [ "$1" == "--list" ] ; then +cat<