diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1130f0c..25fcbd6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,7 +12,7 @@ jobs: steps: - name: "Checkout Repository" uses: actions/checkout@v3 - - name: "Build docker image" + - name: "Build and Run Test Image" run : | docker build . -t test docker run test diff --git a/Dockerfile b/Dockerfile index 57c6d1e..d1a1fa3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,4 +11,4 @@ RUN pip3 install ansible ADD ansible /ansible COPY ansible/homelab/hosts /etc/ansible/hosts -CMD [ "ansible-playbook", "/ansible/homelab/playbooks/setup-home-lab.yml", "-v"] +CMD [ "ansible-playbook", "/ansible/homelab/playbooks/setup-home-lab.yml", "-v","--connection", "local"] diff --git a/ansible/homelab/playbooks/setup-home-lab.yml b/ansible/homelab/playbooks/setup-home-lab.yml index ee6126c..0a08b90 100644 --- a/ansible/homelab/playbooks/setup-home-lab.yml +++ b/ansible/homelab/playbooks/setup-home-lab.yml @@ -1,6 +1,5 @@ --- - hosts: servers - connection: local tasks: - name: Update and upgrade apt packages become: true @@ -15,7 +14,10 @@ state: latest update_cache: true - - name: Install JQ + - name: Install & Configure Sudo + import_tasks: ../tasks/install-sudo-tasks.yml + + - name: Install Dev Tooling import_tasks: ../tasks/install-dev-tooling-tasks.yml - name: Install Docker diff --git a/ansible/homelab/tasks/install-sudo-tasks.yml b/ansible/homelab/tasks/install-sudo-tasks.yml new file mode 100644 index 0000000..dc88337 --- /dev/null +++ b/ansible/homelab/tasks/install-sudo-tasks.yml @@ -0,0 +1,27 @@ +--- +# https://stackoverflow.com/questions/37333305/ansible-create-a-user-with-sudo-privileges +- name: Install Sudo + apt: + pkg: + - sudo + state: latest + update_cache: true + +- name: Make sure we have a 'cianhatton' group + group: + name: cianhatton + state: present +- name: Allow 'cianhatton' group to have passwordless sudo + lineinfile: + dest: /etc/sudoers + state: present + regexp: '^%cianhatton' + line: '%cianhatton ALL=(ALL) NOPASSWD: ALL' + validate: 'visudo -cf %s' + +- name: Add User + ansible.builtin.user: + name: cianhatton + comment: Cian Hatton + uid: 1000 + group: cianhatton \ No newline at end of file diff --git a/ansible/playbooks/vm-test.yml b/ansible/playbooks/vm-test.yml deleted file mode 100644 index 95bb4b5..0000000 --- a/ansible/playbooks/vm-test.yml +++ /dev/null @@ -1,49 +0,0 @@ ---- -- hosts: servers - connection: local - tasks: - - name: Update and upgrade apt packages - become: true - apt: - upgrade: yes - update_cache: yes - cache_valid_time: 86400 - - - name: Install aptitude - apt: - name: aptitude - state: latest - update_cache: true - - - name: Install required system packages - apt: - pkg: - - apt-transport-https - - ca-certificates - - curl - - software-properties-common - - python3-pip - - virtualenv - - python3-setuptools - state: latest - update_cache: true - - - name: Add Docker GPG apt Key - apt_key: - url: https://download.docker.com/linux/ubuntu/gpg - state: present - - - name: Add Docker Repository - apt_repository: - repo: deb https://download.docker.com/linux/ubuntu focal stable - state: present - - - name: Update apt and install docker-ce - apt: - name: docker-ce - state: latest - update_cache: true - - - name: Install Docker Module for Python - pip: - name: docker \ No newline at end of file