From 2706dc7d573f114d81d64db080520df1d8ba024f Mon Sep 17 00:00:00 2001 From: Bryan Joshua Pedini Date: Wed, 16 Mar 2022 12:59:37 +0100 Subject: [PATCH] first code commit --- ansible.cfg | 4 ++++ inventory.ini | 2 ++ main.yml | 7 +++++++ tasks/personal-linux-config-server.yml | 4 ++++ tasks/personal-linux-config.yml | 16 ++++++++++++++++ tasks/ssh-keys.yml | 26 ++++++++++++++++++++++++++ 6 files changed, 59 insertions(+) create mode 100644 ansible.cfg create mode 100644 inventory.ini create mode 100644 main.yml create mode 100644 tasks/personal-linux-config-server.yml create mode 100644 tasks/personal-linux-config.yml create mode 100644 tasks/ssh-keys.yml diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..c2a3cc5 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,4 @@ +[defaults] +nocows = True +inventory = ./inventory.ini +interpreter_python = auto_silent diff --git a/inventory.ini b/inventory.ini new file mode 100644 index 0000000..0dd74f1 --- /dev/null +++ b/inventory.ini @@ -0,0 +1,2 @@ +[localhost] +127.0.0.1 diff --git a/main.yml b/main.yml new file mode 100644 index 0000000..4d72ba1 --- /dev/null +++ b/main.yml @@ -0,0 +1,7 @@ +--- +- hosts: all + become: true + tasks: + - import_tasks: tasks/personal-linux-config.yml + - import_tasks: tasks/personal-linux-config-server.yml + - import_tasks: tasks/ssh-keys.yml diff --git a/tasks/personal-linux-config-server.yml b/tasks/personal-linux-config-server.yml new file mode 100644 index 0000000..6369138 --- /dev/null +++ b/tasks/personal-linux-config-server.yml @@ -0,0 +1,4 @@ +--- +- name: Ensure the server config changes are deployed + ansible.builtin.shell: + cmd: sh -c "cd /root/personal-linux-config; bash /root/personal-linux-config/deploy.sh" diff --git a/tasks/personal-linux-config.yml b/tasks/personal-linux-config.yml new file mode 100644 index 0000000..b05471d --- /dev/null +++ b/tasks/personal-linux-config.yml @@ -0,0 +1,16 @@ +--- +- name: Ensure the hostname package is installed and updated + ansible.builtin.apt: + update_cache: yes + cache_valid_time: 0 + name: hostname + state: latest +- name: Ensure the personal-linux-config repositories is updated + ansible.builtin.git: + dest: /root/personal-linux-config + repo: https://git.bjphoster.com/b.pedini/personal-linux-config + clone: yes + update: yes +- name: Ensure the config changes are deployed + ansible.builtin.shell: + cmd: sh -c "cd /root/personal-linux-config; bash /root/personal-linux-config/deploy.sh" diff --git a/tasks/ssh-keys.yml b/tasks/ssh-keys.yml new file mode 100644 index 0000000..caac3e4 --- /dev/null +++ b/tasks/ssh-keys.yml @@ -0,0 +1,26 @@ +--- +- name: Ensure the .ssh folder is present and has the right permissions + ansible.builtin.file: + path: ~/.ssh + mode: 0700 + state: directory +- name: Ensure the authorized_keys file is present and has the right permissions + ansible.builtin.file: + path: ~/.ssh/authorized_keys + mode: 0600 + state: present +- name: Check if the "bryanpedini@bryanbox.home.bjphoster.cloud" key is present + ansible.builtin.lineinfile: + path: ~/.ssh/authorized_keys + value: | + # bryanpedini@bryanbox.home.bjphoster.cloud + check_mode: true + register: bryanbox_key +- name: Ensure the "bryanpedini@bryanbox.home.bjphoster.cloud" key is present + ansible.builtin.lineinfile: + path: ~/.ssh/authorized_keys + insertafter: EOF + value: | + # bryanpedini@bryanbox.home.bjphoster.cloud + ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAEAQC2x86/7D1kVAHIz9GIns9sjeyr9ziriWo9ittbyNUBbE8O+FOC4ew3MOl8Z3g47vGu1aQ7+pOGCD8BMpTx1k0RX7tqegqoHqHvjbAzuYkBJAcJTUj/nzNEK5fuG5rND2cnTM8SCY+WOxyJvNi9pOYkKyv2OWq63t0irLI+wHY9J/Yf0EUwlGfDSJCy5CqanInWF1eL8FgUL0+84sue++sczoeHCSMw751xvSWFOnj8lbiANWP/A9t2bKe814Jog/yOspwKOJtXp9sgkhX1TsoyUfyBYyJol4Qwlqr5Jfh0sqGFe9F2HZtPLYvb1l+S6H64Y+Xql58bzWDpfY/noHBqprh16HA+46kHPZRG6d8k0JT4DmViBWWRNyzB0K5MzCHc8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