diff --git a/defaults/main.yml b/defaults/main.yml index 1ab96e9..f21bc30 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -32,4 +32,4 @@ perform_uninstall: false custom_unit_properties: {} custom_miner_properties: {} -managed_services: ['service', 'miner'] +managed_services: ['lotus'] diff --git a/handlers/main.yml b/handlers/main.yml index 4301a92..a8efbf2 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -5,6 +5,7 @@ name: lotus state: restarted listen: Restart service + ignore_errors: true - name: Stop lotus systemd service become: true @@ -12,14 +13,14 @@ name: lotus state: stopped enabled: false - listen: Uninstall Lotus + listen: Uninstall service - name: Remove Lotus systemd service file become: true file: path: "/etc/systemd/system/lotus.service" state: absent - listen: Uninstall Lotus + listen: Uninstall service - name: Stop lotus storage miner systemd service become: true @@ -27,35 +28,35 @@ name: lotus-storage-miner state: stopped enabled: false - listen: Uninstall Lotus + listen: Uninstall service - name: Remove Lotus storage miner systemd service file become: true file: path: "/etc/systemd/system/lotus-storage-miner.service" state: absent - listen: Uninstall Lotus + listen: Uninstall service - name: Remove lotus install dir become: true file: path: "{{ install_dir }}" state: absent - listen: Uninstall Lotus + listen: Uninstall service - name: Remove lotus path dir become: true file: path: "{{ lotus_path }}" state: absent - listen: Uninstall Lotus + listen: Uninstall service - name: Remove lotus storage path dir become: true file: path: "{{ lotus_storage_path }}" state: absent - listen: Uninstall Lotus + listen: Uninstall service - name: Remove lotus user become: true @@ -63,11 +64,11 @@ name: "{{ lotus_user }}" state: absent remove: true - listen: Uninstall Lotus + listen: Uninstall service - name: Remove lotus group become: true group: name: "{{ lotus_user }}" state: absent - listen: Uninstall Lotus + listen: Uninstall service diff --git a/kitchen.yml b/kitchen.yml index dd07dca..00d31fa 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -28,6 +28,7 @@ provisioner: ansible_verbose: true ansible_cfg_path: test/ansible.cfg requirements_path: test/requirements-test.yml + idempotency_test: true verifier: name: inspec @@ -89,6 +90,10 @@ suites: - name: install_archive provisioner: playbook: test/integration/install/install_archive/default_playbook.yml + ansible_extra_flags: '--skip-tags=config,launch' + idempotency_skip_tags: + - config + - launch verifier: inspec_tests: - path: test/integration/install/install_archive @@ -99,6 +104,10 @@ suites: - name: install_source provisioner: playbook: test/integration/install/install_source/default_playbook.yml + ansible_extra_flags: '--skip-tags=config,launch' + idempotency_skip_tags: + - config + - launch verifier: inspec_tests: - path: test/integration/install/install_source @@ -139,6 +148,7 @@ suites: - name: uninstall provisioner: playbook: test/integration/uninstall/default_playbook.yml + idempotency_test: false verifier: inspec_tests: - path: test/integration/uninstall diff --git a/tasks/common/install.yml b/tasks/common/install.yml index 85b67af..ae0425a 100644 --- a/tasks/common/install.yml +++ b/tasks/common/install.yml @@ -34,3 +34,16 @@ include_tasks: "common/install/{{ install_type }}_install.yml" tags: - install + +- name: Create symbolic links to managed services binaries + become: true + when: install_type == "archive" + file: + src: "{{ install_dir }}/{{ item }}" + dest: "/usr/local/bin/{{ item }}" + state: link + loop: "{{ managed_services }}" + notify: + - Restart service + tags: + - install diff --git a/tasks/common/install/archive_install.yml b/tasks/common/install/archive_install.yml index 01d8d27..47e61fe 100644 --- a/tasks/common/install/archive_install.yml +++ b/tasks/common/install/archive_install.yml @@ -30,16 +30,3 @@ tags: - install - archive - -- name: Create a symbolic link to /usr/local/bin/lotus - become: true - when: install_type == "archive" - file: - src: "{{ install_dir }}/lotus" - dest: /usr/local/bin/lotus - state: link - notify: - - Restart service - tags: - - install - - archive diff --git a/tasks/common/install/source_install.yml b/tasks/common/install/source_install.yml index 32893af..baba6f4 100644 --- a/tasks/common/install/source_install.yml +++ b/tasks/common/install/source_install.yml @@ -18,6 +18,7 @@ target: clean environment: PATH: /usr/local/bin:{{ ansible_env.PATH }} + changed_when: false tags: - install - source @@ -30,6 +31,7 @@ target: all environment: PATH: /usr/local/bin:{{ ansible_env.PATH }} + changed_when: false tags: - install - source @@ -42,6 +44,7 @@ target: install environment: PATH: /usr/local/bin:{{ ansible_env.PATH }} + changed_when: false tags: - install - source @@ -54,6 +57,7 @@ owner: "{{ lotus_user }}" group: "{{ lotus_user }}" recurse: true + changed_when: false tags: - install - source diff --git a/tasks/common/launch/miner_launch.yml b/tasks/common/launch/lotus-storage-miner_launch.yml similarity index 97% rename from tasks/common/launch/miner_launch.yml rename to tasks/common/launch/lotus-storage-miner_launch.yml index 5bf4639..7d3cffd 100644 --- a/tasks/common/launch/miner_launch.yml +++ b/tasks/common/launch/lotus-storage-miner_launch.yml @@ -23,6 +23,7 @@ name: lotus-storage-miner state: started enabled: "yes" + changed_when: false tags: - launch - miner diff --git a/tasks/common/launch/service_launch.yml b/tasks/common/launch/lotus_launch.yml similarity index 100% rename from tasks/common/launch/service_launch.yml rename to tasks/common/launch/lotus_launch.yml diff --git a/tasks/common/preflight.yml b/tasks/common/preflight.yml index abbd17e..edf5edf 100644 --- a/tasks/common/preflight.yml +++ b/tasks/common/preflight.yml @@ -14,43 +14,20 @@ block: - name: Broadcast uninstall signal command: /bin/true - notify: Uninstall Lotus - when: perform_uninstall - + notify: + - Uninstall service + rescue: + - name: Ensure flush of handlers + meta: flush_handlers + always: - name: End play following uninstallation meta: end_play - tags: - - always - -- name: Update system packages - become: true - when: go_autoinstall and ansible_os_family|lower == "redhat" - yum: - name: "*" - state: latest - tags: - - preflight - -- name: Add Go-lang backports repository to sources list - become: true - when: go_autoinstall and ansible_distribution|lower == "ubuntu" - apt_repository: - repo: ppa:longsleep/golang-backports - tags: - - preflight - -- name: Update apt packages - become: true - when: go_autoinstall and ansible_os_family|lower == "debian" - apt: - upgrade: 'yes' - update_cache: 'yes' tags: - preflight - name: Download and extract Go-lang become: true - when: go_autoinstall and ansible_distribution|lower != "ubuntu" + when: go_autoinstall unarchive: src: "{{ go_url }}" dest: "{{ go_install_dir }}" @@ -61,18 +38,17 @@ - name: Update system dependencies become: true - when: ansible_distribution|lower != "ubuntu" package: name: "{{ system_dependencies }}" state: present tags: - preflight -- name: Create a symbolic link to /usr/local/bin/go +- name: Create a symbolic link to installed go binary become: true - when: go_autoinstall and ansible_distribution|lower != "Ubuntu" + when: go_autoinstall file: - src: "{{ go_install_dir }}/go" + src: "{{ go_install_dir }}/go/bin/go" dest: /usr/local/bin/go state: link tags: diff --git a/test/integration/config/default_test.rb b/test/integration/config/default_test.rb index 08c351a..6c3875b 100644 --- a/test/integration/config/default_test.rb +++ b/test/integration/config/default_test.rb @@ -1,6 +1,6 @@ title "Lotus configuration integration tests" -describe file('/home/lotus/.lotus/config.toml') do +describe file('/opt/lotus/.lotus/config.toml') do it { should exist } its('owner') { should eq 'lotus' } its('group') { should eq 'lotus' } diff --git a/test/integration/launch/launch_miner/default_playbook.yml b/test/integration/launch/launch_miner/default_playbook.yml index de49e08..eee54ab 100644 --- a/test/integration/launch/launch_miner/default_playbook.yml +++ b/test/integration/launch/launch_miner/default_playbook.yml @@ -5,6 +5,6 @@ - ansible-role-lotus vars: version: v0.1.5 - managed_services: ['service', 'miner'] + managed_services: ['lotus', 'lotus-storage-miner'] extra_run_args: - '--bootstrap' diff --git a/test/integration/launch/launch_service/default_playbook.yml b/test/integration/launch/launch_service/default_playbook.yml index 73bcba8..234a31e 100644 --- a/test/integration/launch/launch_service/default_playbook.yml +++ b/test/integration/launch/launch_service/default_playbook.yml @@ -5,7 +5,8 @@ - ansible-role-lotus vars: install_type: source + go_autoinstall: true git_version: v0.1.5 - managed_services: ['service'] + managed_services: ['lotus'] extra_run_args: - "--bootstrap" diff --git a/vars/ubuntu.yml b/vars/ubuntu.yml index 45a4186..29a34de 100644 --- a/vars/ubuntu.yml +++ b/vars/ubuntu.yml @@ -1,7 +1,6 @@ --- go_install_dir: /usr/bin system_dependencies: - - golang-go - gcc - git - bzr