From 0e2ea5cb361763a458ca6b221d667076643e78ea Mon Sep 17 00:00:00 2001 From: Gabriel Radureau Date: Wed, 10 Jul 2024 15:39:43 +0200 Subject: [PATCH] ansible: begin inventory --- ansible/README.md | 2 +- ansible/arcodange/factory/inventory/hosts.yml | 37 +++++++++++++++++++ .../factory/playbooks/setup/hard_disk.yml | 11 +++++- .../factory/playbooks/setup/setup.yml | 5 ++- ansible/nonroot_ssh_proxy_setup.sh | 2 + 5 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 ansible/arcodange/factory/inventory/hosts.yml diff --git a/ansible/README.md b/ansible/README.md index c6c76a7..61f731a 100644 --- a/ansible/README.md +++ b/ansible/README.md @@ -19,7 +19,7 @@ git clone -q --depth 1 --branch master https://github.com/arcodange/ssh-agent.gi docker run -d --name=ssh-agent docker-ssh-agent:latest docker run --rm --volumes-from=ssh-agent -v ~/.ssh:/.ssh -it docker-ssh-agent:latest ssh-add /root/.ssh/id_rsa docker run --rm -u root --name test --volumes-from=ssh-agent -v $PWD:/home/arcodange/code arcodange-ansible:0.0.0 \ -ansible-playbook ansible/arcodange/factory/playbooks/setup/setup.yml -i pi1,pi2 -u pi -vv +ansible-playbook ansible/arcodange/factory/playbooks/setup/setup.yml -i ansible/arcodange/factory/inventory -vv ``` ### a tool to reuse a ssh agent (not required) diff --git a/ansible/arcodange/factory/inventory/hosts.yml b/ansible/arcodange/factory/inventory/hosts.yml new file mode 100644 index 0000000..76cb81d --- /dev/null +++ b/ansible/arcodange/factory/inventory/hosts.yml @@ -0,0 +1,37 @@ +raspberries: + hosts: + pi1: + ansible_host: pi1.home # setup http://192.168.1.1/ Réseau/DNS + pi2: + ansible_host: pi2.home + + internetPi1: + ansible_host: rg-evry.changeip.co + ansible_port: 51022 + internetPi2: + ansible_host: rg-evry.changeip.co + ansible_port: 52022 + + vars: + ansible_user: pi + +local: + hosts: + pi1: + pi2: + +hard_disk: + hosts: + pi2 # 4To toshiba external hard drive (/dev/sda) + +postgres: + children: + hard_disk: + +gitea: + children: + hard_disk: + +all: + children: + raspberry: \ No newline at end of file diff --git a/ansible/arcodange/factory/playbooks/setup/hard_disk.yml b/ansible/arcodange/factory/playbooks/setup/hard_disk.yml index 23ebe27..c716cf0 100644 --- a/ansible/arcodange/factory/playbooks/setup/hard_disk.yml +++ b/ansible/arcodange/factory/playbooks/setup/hard_disk.yml @@ -7,7 +7,7 @@ # lsblk -fe7 -- uuid des partitions --- - name: Setup Hard Disk - hosts: pi2 + hosts: hard_disk gather_facts: yes become: yes @@ -25,6 +25,15 @@ loop_control: loop_var: mount_point + - name: Set permissions for group docker on /arcodange + ansible.builtin.file: + path: /arcodange + state: directory + recurse: yes + owner: pi + group: docker + mode: u=rwX,g=rX,o=rX + - name: Set ACL for group docker on /arcodange ansible.posix.acl: path: "/arcodange" diff --git a/ansible/arcodange/factory/playbooks/setup/setup.yml b/ansible/arcodange/factory/playbooks/setup/setup.yml index e711da9..340ef3a 100644 --- a/ansible/arcodange/factory/playbooks/setup/setup.yml +++ b/ansible/arcodange/factory/playbooks/setup/setup.yml @@ -1,6 +1,6 @@ --- - name: setup - hosts: all + hosts: raspberries:&local tasks: - name: hello world @@ -8,4 +8,5 @@ msg: Hello world! - name: setup hard disk - ansible.builtin.import_playbook: hard_disk.yml \ No newline at end of file + ansible.builtin.import_playbook: hard_disk.yml + tags: never \ No newline at end of file diff --git a/ansible/nonroot_ssh_proxy_setup.sh b/ansible/nonroot_ssh_proxy_setup.sh index 04bc181..27ef6b3 100644 --- a/ansible/nonroot_ssh_proxy_setup.sh +++ b/ansible/nonroot_ssh_proxy_setup.sh @@ -15,6 +15,8 @@ fi export SSH_AUTH_SOCK=/home/arcodange/.ssh/socket mkdir `dirname $SSH_AUTH_SOCK` +set -x socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork UNIX-CONNECT:$SOCKET_FILE & +set +x chown -R 1000 `dirname $SSH_AUTH_SOCK` echo "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> ~/.profile \ No newline at end of file