From 818a7aaefd5636be3f4f3cb0d33b42cccfa8803c Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Fri, 13 Dec 2019 21:48:59 -0600 Subject: [PATCH] add utils role --- roles/common/tasks/main.yaml | 6 ------ roles/common/vars/main.yaml | 10 ---------- roles/util/defaults/main.yaml | 31 +++++++++++++++++++++++++++++++ roles/util/tasks/Ubuntu.yaml | 10 ++++++++++ roles/util/tasks/main.yaml | 30 ++++++++++++++++++++++++++++++ roles/util/vars/default.yaml | 0 6 files changed, 71 insertions(+), 16 deletions(-) delete mode 100644 roles/common/vars/main.yaml create mode 100644 roles/util/defaults/main.yaml create mode 100644 roles/util/tasks/Ubuntu.yaml create mode 100644 roles/util/tasks/main.yaml create mode 100644 roles/util/vars/default.yaml diff --git a/roles/common/tasks/main.yaml b/roles/common/tasks/main.yaml index 20d3a38..9a151aa 100644 --- a/roles/common/tasks/main.yaml +++ b/roles/common/tasks/main.yaml @@ -15,12 +15,6 @@ hostname: name: "{{ hostname | default(inventory_hostname) }}" -- name: install system utilities - package: - name: "{{ item }}" - state: present - with_items: "{{ sys_utils }}" - - name: configure system timezone timezone: name: "{{ timezone }}" diff --git a/roles/common/vars/main.yaml b/roles/common/vars/main.yaml deleted file mode 100644 index e5f8026..0000000 --- a/roles/common/vars/main.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -sys_utils: - - git - - vim - - tmux - - dnsutils - - ldnsutils - - tcpdump - -# vim:ft=yaml.ansible: diff --git a/roles/util/defaults/main.yaml b/roles/util/defaults/main.yaml new file mode 100644 index 0000000..9a2e13b --- /dev/null +++ b/roles/util/defaults/main.yaml @@ -0,0 +1,31 @@ +--- +util_vim_ppa_state: present +util_git_ppa_state: present + +util_package_state: latest + +util_packages: + editors: + - vim + devel: + - git + - mercurial + - fossil + network: + - nmap + - tcpdump + - curl + - wget + - lftp + - rsync + - dnsutils + - ldnsutils + - sipcalc + math: + - bc + misc: + - tmux + - moreutils + security: + - gnupg + - pass diff --git a/roles/util/tasks/Ubuntu.yaml b/roles/util/tasks/Ubuntu.yaml new file mode 100644 index 0000000..89c7e73 --- /dev/null +++ b/roles/util/tasks/Ubuntu.yaml @@ -0,0 +1,10 @@ +--- +- name: add vim ppa + apt_repository: + repo: ppa:jonathonf/vim + state: "{{ util_vim_ppa_state }}" + +- name: add git ppa + apt_repository: + repo: ppa:git-core/ppa + state: "{{ util_git_ppa_state }}" diff --git a/roles/util/tasks/main.yaml b/roles/util/tasks/main.yaml new file mode 100644 index 0000000..6745c5c --- /dev/null +++ b/roles/util/tasks/main.yaml @@ -0,0 +1,30 @@ +--- +- name: gather os specific variables + include_vars: "{{ lookup('first_found', possible_files) }}" + vars: + possible_files: + files: + - "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml" + - "{{ ansible_distribution }}.yaml" + - "{{ ansible_os_family }}.yaml" + - "default.yaml" + paths: + - vars + +- name: include os specific tasks + include_tasks: "{{ lookup('first_found', possible_files) }}" + vars: + possible_files: + files: + - "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml" + - "{{ ansible_distribution }}.yaml" + - "{{ ansible_os_family }}.yaml" + - "default.yaml" + paths: + - tasks + +- name: install packages + package: + name: "{{ item.value }}" + state: "{{ util_package_state }}" + loop: "{{ (util_packages | default({})) | dict2items }}" diff --git a/roles/util/vars/default.yaml b/roles/util/vars/default.yaml new file mode 100644 index 0000000..e69de29