diff --git a/playbooks/master.yml b/playbooks/master.yml new file mode 100644 index 0000000..ec46d75 --- /dev/null +++ b/playbooks/master.yml @@ -0,0 +1,3 @@ +- import_playbook: user.yml +- import_playbook: software.yml +- import_playbook: script.yml diff --git a/playbooks/script.yml b/playbooks/script.yml new file mode 100644 index 0000000..66fe8e2 --- /dev/null +++ b/playbooks/script.yml @@ -0,0 +1,12 @@ +- name: copying over collector.py + hosts: server + become: true + + tasks: + - name: copying script + ansible.builtin.copy: + src: ../collector.py + dest: /home/user/collector.py + owner: user + group: user + mode: 0755 diff --git a/playbooks/software.yml b/playbooks/software.yml new file mode 100644 index 0000000..f236c9f --- /dev/null +++ b/playbooks/software.yml @@ -0,0 +1,14 @@ +- name: install software + hosts: server + become: true + tasks: + + - name: update apt cache for debian machines + apt: + update_cache: yes + when: ansible_facts['os_family'] == "Debian" + + - name: installing + ansible.builtin.package: + name: python3-psutil + state: present diff --git a/playbooks/user.yml b/playbooks/user.yml new file mode 100644 index 0000000..7b14fdc --- /dev/null +++ b/playbooks/user.yml @@ -0,0 +1,22 @@ +- name: setting up user + hosts: server + become: true + tasks: + + - name: creating user + ansible.builtin.user: + name: user + create_home: yes + shell: /bin/bash + + - name: making .ssh directory + ansible.builtin.file: + path: /home/user/.ssh + owner: user + group: user + state: directory + + - ansible.posix.authorized_key: + user: user + key: "{{ lookup('file', '/path/2/key.pub') }}" + state: present