From 0865f5069102592fe0b3edb7fb7719c2f586b675 Mon Sep 17 00:00:00 2001 From: Arya Kiran Date: Sat, 18 Mar 2023 22:52:37 +0530 Subject: [PATCH] add stuff actually --- README.md | 6 ++++++ files/akis.pub | 0 files/arya.pub | 2 ++ files/devrand.pub | 0 files/midou.pub | 0 playbook.yaml | 48 ++++++++++++++++++++++++++++++++++++++++------- requirements.yml | 2 ++ 7 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 files/akis.pub create mode 100644 files/arya.pub create mode 100644 files/devrand.pub create mode 100644 files/midou.pub create mode 100644 requirements.yml diff --git a/README.md b/README.md index e69de29..0d36387 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,6 @@ +# Testing ansible +``` +ansible-galaxy collection install -r requirements.yml +ansible-playbook playbook.yaml +``` + diff --git a/files/akis.pub b/files/akis.pub new file mode 100644 index 0000000..e69de29 diff --git a/files/arya.pub b/files/arya.pub new file mode 100644 index 0000000..747ed23 --- /dev/null +++ b/files/arya.pub @@ -0,0 +1,2 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICeUQKFE6j+legQS2aam8VlwaGJ1r5BfJevbMUxpAi6N aryakiran@zohomail.eu + diff --git a/files/devrand.pub b/files/devrand.pub new file mode 100644 index 0000000..e69de29 diff --git a/files/midou.pub b/files/midou.pub new file mode 100644 index 0000000..e69de29 diff --git a/playbook.yaml b/playbook.yaml index 397949a..72cdd27 100644 --- a/playbook.yaml +++ b/playbook.yaml @@ -1,9 +1,43 @@ -- name: My first play +--- +- name: Install shit hosts: ansibletest tasks: - - name: Ping my hosts - ansible.builtin.ping: - - name: Print message - ansible.builtin.debug: - msg: Hello world - + - name: Std Repo stuff + apt: + update_cache: true + name: + - vim + - curl + - wget + - sudo +- name: Add users + hosts: ansibletest + vars: + users: + - akis + - arya + - devrand + - midou + tasks: + - name: Add user + ansible.builtin.user: + name: "{{ item }}" + group: users + groups: users,sudo + password: $1$cGVmF3CO$CoJyouR8KHiol1xm8zF3l. + shell: /bin/bash + update_password: on_create + with_items: + - "{{ users }}" + - name: "Add authorized keys" + authorized_key: + user: "{{ item }}" + key: "{{ lookup('file', 'files/'+ item + '.pub') }}" + with_items: + - "{{ users }}" + - name: "Allow admin users to sudo without a password" + lineinfile: + dest: "/etc/sudoers" # path: in version 2.3 + state: "present" + regexp: "^%sudo" + line: "%sudo ALL=(ALL) NOPASSWD: ALL" diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..04a5590 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,2 @@ +collections: +- name: community.docker