From 007d5809e627fab1298e8b055d11ae54b1ce8758 Mon Sep 17 00:00:00 2001 From: Larry Smith Jr Date: Tue, 11 Sep 2018 22:07:50 -0400 Subject: [PATCH] Cleaned up tasks and etc. --- README.md | 49 +++-------- defaults/main.yml | 9 +- handlers/main.yml | 3 +- meta/main.yml | 136 +---------------------------- tasks/config_tftpd.yml | 21 ++--- tasks/debian.yml | 14 +-- templates/etc/default/tftpd-hpa.j2 | 4 +- 7 files changed, 39 insertions(+), 197 deletions(-) diff --git a/README.md b/README.md index 7382b23..5bbd2c4 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,22 @@ -Role Name -========= +# ansible-tftpd-hpa -An [Ansible] role to install/configure [tftpd-hpa] +An [Ansible](https://www.ansible.com) role to install/configure `tftpd-hpa`. -Requirements ------------- +## Requirements None -Role Variables --------------- +## Role Variables -``` ---- -# defaults file for ansible-tftpd-hpa +[defaults/main.yml](defaults/main.yml) -# Defines tftp root directory -tftp_directory: '/var/lib/tftpboot' - -# Defines tftp options for daemon...(-c allow new files to be created) -tftp_options: '--secure -c' - -tftp_netboot_file: 'netboot.tar.gz' -tftp_netboot_url: 'http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-amd64/current/images/netboot' -``` - -Dependencies ------------- +## Dependencies None -Example Playbook ----------------- +## Example Playbook -``` +```yaml --- - hosts: tftp_servers become: true @@ -43,18 +26,14 @@ Example Playbook tasks: ``` -License -------- +## License -BSD +MIT -Author Information ------------------- +## Author Information Larry Smith Jr. -- @mrlesmithjr -- http://everythingshouldbevirtual.com -- mrlesmithjr [at] gmail.com -[Ansible]: -[tftpd-hpa]: +- [@mrlesmithjr](https://www.twitter.com/mrlesmithjr) +- [EverythingShouldBeVirtual](http://www.everythingshouldbevirtual.com) +- [mrlesmithjr@gmail.com](mailto:mrlesmithjr@gmail.com) \ No newline at end of file diff --git a/defaults/main.yml b/defaults/main.yml index f6c1b7d..0517767 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -2,10 +2,11 @@ # defaults file for ansible-tftpd-hpa # Defines tftp root directory -tftp_directory: '/var/lib/tftpboot' +tftp_directory: /var/lib/tftpboot # Defines tftp options for daemon...(-c allow new files to be created) -tftp_options: '--secure -c' +tftp_options: --secure -c -tftp_netboot_file: 'netboot.tar.gz' -tftp_netboot_url: 'http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-amd64/current/images/netboot' +tftp_netboot_enable: false +tftp_netboot_file: netboot.tar.gz +tftp_netboot_url: http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-amd64/current/images/netboot diff --git a/handlers/main.yml b/handlers/main.yml index 42d686c..5a39849 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -2,5 +2,6 @@ # handlers file for ansible-tftpd-hpa - name: restart tftpd-hpa service: - name: "tftpd-hpa" + name: tftpd-hpa state: restarted + become: true diff --git a/meta/main.yml b/meta/main.yml index 8b879f7..7489f21 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,150 +1,18 @@ galaxy_info: author: Larry Smith Jr. description: An [Ansible] role to install/configure [tftpd-hpa] - #company: your company (optional) - - # If the issue tracker for your role is not on github, uncomment the - # next line and provide a value - # issue_tracker_url: http://example.com/issue/tracker - - # Some suggested licenses: - # - BSD (default) - # - MIT - # - GPLv2 - # - GPLv3 - # - Apache - # - CC-BY - license: license (GPLv2, CC-BY, etc) + license: MIT min_ansible_version: 1.2 - # Optionally specify the branch Galaxy will use when accessing the GitHub - # repo for this role. During role install, if no tags are available, - # Galaxy will use this branch. During import Galaxy will access files on - # this branch. If travis integration is cofigured, only notification for this - # branch will be accepted. Otherwise, in all cases, the repo's default branch - # (usually master) will be used. - #github_branch: - - # - # Below are all platforms currently available. Just uncomment - # the ones that apply to your role. If you don't see your - # platform on this list, let us know and we'll get it added! - # platforms: - #- name: EL - # versions: - # - all - # - 5 - # - 6 - # - 7 - #- name: GenericUNIX - # versions: - # - all - # - any - #- name: Solaris - # versions: - # - all - # - 10 - # - 11.0 - # - 11.1 - # - 11.2 - # - 11.3 - #- name: Fedora - # versions: - # - all - # - 16 - # - 17 - # - 18 - # - 19 - # - 20 - # - 21 - # - 22 - #- name: Windows - # versions: - # - all - # - 2012R2 - #- name: SmartOS - # versions: - # - all - # - any - #- name: opensuse - # versions: - # - all - # - 12.1 - # - 12.2 - # - 12.3 - # - 13.1 - # - 13.2 - #- name: Amazon - # versions: - # - all - # - 2013.03 - # - 2013.09 - #- name: GenericBSD - # versions: - # - all - # - any - #- name: FreeBSD - # versions: - # - all - # - 8.0 - # - 8.1 - # - 8.2 - # - 8.3 - # - 8.4 - # - 9.0 - # - 9.1 - # - 9.1 - # - 9.2 - name: Ubuntu versions: - # - all - # - lucid - # - maverick - # - natty - # - oneiric - # - precise - # - quantal - # - raring - # - saucy - trusty - # - utopic - # - vivid - xenial - #- name: SLES - # versions: - # - all - # - 10SP3 - # - 10SP4 - # - 11 - # - 11SP1 - # - 11SP2 - # - 11SP3 - #- name: GenericLinux - # versions: - # - all - # - any - #- name: Debian - # versions: - # - all - # - etch - # - jessie - # - lenny - # - squeeze - # - wheezy galaxy_tags: - # List tags for your role here, one per line. A tag is - # a keyword that describes and categorizes the role. - # Users find roles by searching for tags. Be sure to - # remove the '[]' above if you add tags to this list. - # - # NOTE: A tag is limited to a single word comprised of - # alphanumeric characters. Maximum 20 tags per role. - system - network + dependencies: [] - # List your role dependencies here, one per line. - # Be sure to remove the '[]' above if you add dependencies - # to this list. diff --git a/tasks/config_tftpd.yml b/tasks/config_tftpd.yml index e756f8e..1a78d57 100644 --- a/tasks/config_tftpd.yml +++ b/tasks/config_tftpd.yml @@ -5,34 +5,31 @@ state: directory owner: tftp group: tftp + become: true - name: config_tftpd | configuring tftpd template: - src: "etc/default/tftpd-hpa.j2" - dest: "/etc/default/tftpd-hpa" - owner: root - group: root - mode: 0644 - notify: restart tftpd-hpa - -- name: config_tftpd | configuring inetd - template: - src: "etc/inetd.conf.j2" - dest: "/etc/inetd.conf" + src: etc/default/tftpd-hpa.j2 + dest: /etc/default/tftpd-hpa owner: root group: root mode: 0644 + become: true notify: restart tftpd-hpa - name: config_tftpd | Downloading Netboot get_url: url: "{{ tftp_netboot_url }}/{{ tftp_netboot_file }}" dest: "{{ tftp_directory }}/{{ tftp_netboot_file }}" + become: true + when: tftp_netboot_enable - name: config_tftpd | Extracting Netboot unarchive: src: "{{ tftp_directory }}/{{ tftp_netboot_file }}" dest: "{{ tftp_directory }}" - copy: no + copy: false args: creates: "{{ tftp_directory }}/pxelinux.0" + become: true + when: tftp_netboot_enable diff --git a/tasks/debian.yml b/tasks/debian.yml index b184597..d3caa1b 100644 --- a/tasks/debian.yml +++ b/tasks/debian.yml @@ -1,12 +1,6 @@ --- -- name: debian | updating apt-cache +- name: debian | Installing tftpd-hpa apt: - update_cache: true - cache_valid_time: 86400 - -- name: debian | installing packages - apt: - name: "{{ item }}" - with_items: - - tftpd-hpa - - inetutils-inetd + name: tftpd-hpa + state: present + become: true diff --git a/templates/etc/default/tftpd-hpa.j2 b/templates/etc/default/tftpd-hpa.j2 index 656aad3..5eb549b 100644 --- a/templates/etc/default/tftpd-hpa.j2 +++ b/templates/etc/default/tftpd-hpa.j2 @@ -1,6 +1,8 @@ -# /etc/default/tftpd-hpa +{{ ansible_managed|comment }} TFTP_USERNAME="tftp" TFTP_DIRECTORY="{{ tftp_directory }}" TFTP_ADDRESS="[::]:69" TFTP_OPTIONS="{{ tftp_options }}" + +RUN_DAEMON="yes"