diff --git a/inventories/host_vars/runner.yml b/inventories/host_vars/runner.yml new file mode 100644 index 0000000..b4b13f3 --- /dev/null +++ b/inventories/host_vars/runner.yml @@ -0,0 +1,4 @@ +--- +apt: + - python3-pip + - zsh diff --git a/runner.yml b/runner.yml new file mode 100644 index 0000000..3a7b1cc --- /dev/null +++ b/runner.yml @@ -0,0 +1,73 @@ +--- +- name: Play for runner.hayaworld.local + hosts: runner + remote_user: hayato + gather_facts: true + become: true + + vars_files: + - inventories/host_vars/runner.yml + - inventories/host_vars/networks.yml + + tasks: + - name: Set Hostname + ansible.builtin.hostname: + name: "{{ network.runner.hostname }}" + tags: + - network + + - name: Put authorized Key + ansible.builtin.import_tasks: + file: tasks/authorized_keys.yml + + - name: Put motd file + ansible.builtin.import_tasks: + file: tasks/motd.yml + vars: + shortname: "{{ network.runner.shortname }}" + + - name: Disable SELinux + ansible.builtin.import_tasks: + file: tasks/stop-selinux.yml + + - name: Set Timezones + ansible.builtin.import_tasks: + file: tasks/timezone.yml + + - name: Stop Apt-daily + ansible.builtin.import_tasks: + file: tasks/stop-apt-daily.yml + + - name: Stop cloud-init + ansible.builtin.import_tasks: + file: tasks/stop-cloud-init.yml + + - name: Apt install + ansible.builtin.import_tasks: + file: tasks/console/apt.yml + + - name: Add user for runner execution + ansible.builtin.user: + name: runner + shell: /bin/bash + groups: sudo + append: true + expires: -1 + + - name: Put authorized Key for runner + ansible.builtin.import_tasks: + file: tasks/authorized_keys.yml + + - name: Install Docker(ce) + ansible.builtin.import_role: + name: geerlingguy.docker + vars: + docker_edition: 'ce' + docker_packages_state: present + docker_service_manage: true + docker_service_state: started + docker_service_enabled: true + docker_restart_handler_state: restarted + docker_users: + - hayato + - runner diff --git a/tasks/runner/authorized_keys.yml b/tasks/runner/authorized_keys.yml new file mode 100644 index 0000000..951e4df --- /dev/null +++ b/tasks/runner/authorized_keys.yml @@ -0,0 +1,20 @@ +--- +- name: "Make directory ~/.ssh/" + ansible.builtin.file: + path: /home/runner/.ssh/ + state: directory + owner: runner + group: runner + mode: '0700' + tags: + - authorized_keys + +- name: "Put authorized_keys" + ansible.builtin.copy: + src: templates/home/hayato/.ssh/authorized_keys + dest: /home/runner/.ssh/authorized_keys + owner: runner + group: runner + mode: '0600' + tags: + - authorized_keys diff --git a/templates/runner/etc/motd b/templates/runner/etc/motd new file mode 100644 index 0000000..09f1f9a --- /dev/null +++ b/templates/runner/etc/motd @@ -0,0 +1,4 @@ + _ __ _ _ _ __ _ __ ___ _ __ +| '__| | | | '_ \| '_ \ / _ \ '__| +| | | |_| | | | | | | | __/ | +|_| \__,_|_| |_|_| |_|\___|_|