diff --git a/playbook.yml b/playbook.yml index 9a71856..949ebd3 100644 --- a/playbook.yml +++ b/playbook.yml @@ -1,6 +1,6 @@ --- - hosts: all - gather_facts: False + gather_facts: false become: true vars: base_domain: data.coop @@ -36,6 +36,6 @@ - import_role: name: ubuntu_base tags: - - base_only + - base_only - import_role: name: docker diff --git a/roles/ubuntu_base/tasks/base.yml b/roles/ubuntu_base/tasks/base.yml index bf4b0f1..13774f0 100644 --- a/roles/ubuntu_base/tasks/base.yml +++ b/roles/ubuntu_base/tasks/base.yml @@ -2,6 +2,7 @@ - name: Install necessary packages via apt apt: name: "{{ packages }}" + state: latest vars: packages: - aptitude @@ -9,7 +10,11 @@ - apparmor - haveged - mosh - - srvadmin-all # Dell OpenManage + +- name: Install Dell OpenManage + apt: + name: srvadmin-all + when: ansible_virtualization_role != "guest" - name: Install necessary packages via pip pip: @@ -17,6 +22,5 @@ state: latest vars: packages: - - pip # upgrade needed for docker-compose to install - docker - docker-compose diff --git a/roles/ubuntu_base/tasks/custom-apt-repos.yml b/roles/ubuntu_base/tasks/dell-apt-repo.yml similarity index 68% rename from roles/ubuntu_base/tasks/custom-apt-repos.yml rename to roles/ubuntu_base/tasks/dell-apt-repo.yml index 7bb042d..b7d9d48 100644 --- a/roles/ubuntu_base/tasks/custom-apt-repos.yml +++ b/roles/ubuntu_base/tasks/dell-apt-repo.yml @@ -1,15 +1,15 @@ --- -- name: import dell apt signing key +- name: Import dell apt signing key apt_key: id: "1285491434D8786F" keyserver: "keyserver.ubuntu.com" -- name: "configure dell apt repo" +- name: Configure dell apt repo apt_repository: repo: "deb https://linux.dell.com/repo/community/openmanage/10101/focal focal main" - state: "present" + state: present -- name: "restrict dell apt repo" +- name: Restrict dell apt repo" copy: dest: "/etc/apt/preferences.d/dell" content: | @@ -17,7 +17,3 @@ Package: * Pin: origin "linux.dell.com" Pin-Priority: 400 - -- name: update apt cache - apt: - update_cache: yes diff --git a/roles/ubuntu_base/tasks/facts.yml b/roles/ubuntu_base/tasks/facts.yml new file mode 100644 index 0000000..abd9a28 --- /dev/null +++ b/roles/ubuntu_base/tasks/facts.yml @@ -0,0 +1,3 @@ +--- +- name: Gather facts + gather_facts: diff --git a/roles/ubuntu_base/tasks/main.yml b/roles/ubuntu_base/tasks/main.yml index 36c4488..ba1be61 100644 --- a/roles/ubuntu_base/tasks/main.yml +++ b/roles/ubuntu_base/tasks/main.yml @@ -1,8 +1,11 @@ --- - import_tasks: ssh.yml tags: [change-ssh-port] -- import_tasks: custom-apt-repos.yml - tags: [setup-custom-apt] +- import_tasks: facts.yml + tags: [gather-facts] +- import_tasks: dell-apt-repo.yml + tags: [setup-dell-apt-repo] + when: ansible_virtualization_role != "guest" - import_tasks: upgrade.yml tags: [do-full-system-upgrade] - import_tasks: base.yml diff --git a/roles/ubuntu_base/tasks/ssh.yml b/roles/ubuntu_base/tasks/ssh.yml index e0bbe1e..fa11cd1 100644 --- a/roles/ubuntu_base/tasks/ssh.yml +++ b/roles/ubuntu_base/tasks/ssh.yml @@ -2,8 +2,7 @@ - name: Check if SSH port is already configured wait_for: port: 19022 - state: started - host: "{{ inventory_hostname }}" + host: "{{ ansible_host }}" connect_timeout: 5 timeout: 10 become: false @@ -36,7 +35,7 @@ - name: Ensure sshd is reloaded if needed meta: flush_handlers -- name: Change ansible_port 19022 +- name: Change Ansible port to 19022 set_fact: ansible_port: 19022 when: ssh_changed is defined