diff --git a/defaults/main.yml b/defaults/main.yml index 637b943..bed10c8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -19,7 +19,7 @@ nu_plugins: - nu_plugin_inc - nu_plugin_query - nu_plugin_formats -min_glibc_version: '2.29' + - nu_plugin_polars config_urls: - name: config.nu url: "https://raw.githubusercontent.com/nushell/nushell/{{ _nushell_version }}/crates/nu-utils/src/sample_config/default_config.nu" diff --git a/molecule/banner/molecule.yml b/molecule/banner/molecule.yml index 91965c2..a19a306 100644 --- a/molecule/banner/molecule.yml +++ b/molecule/banner/molecule.yml @@ -6,7 +6,7 @@ driver: name: docker platforms: - name: instance - image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest" + image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest" command: "" volumes: - /sys/fs/cgroup:/sys/fs/cgroup:rw @@ -18,7 +18,7 @@ platforms: cgroupns_mode: host provisioner: name: ansible - log: false + log: true playbooks: prepare: ../common/prepare.yml verifier: diff --git a/molecule/banner/verify.yml b/molecule/banner/verify.yml index 35d1dd4..91a39b0 100644 --- a/molecule/banner/verify.yml +++ b/molecule/banner/verify.yml @@ -6,6 +6,7 @@ vars: nu_users: - ansible + nushell_binary_path: /usr/local/bin tasks: - name: Include default assertions ansible.builtin.include_tasks: "../common/{{ file }}.yml" @@ -43,7 +44,7 @@ loop: "{{ nu_users }}" - name: Run nushell command to check for config errors - ansible.builtin.command: "nu -n -c 'nu-check /home/{{ item[0] }}/{{ nushell_config_path }}/{{ item[1] }}'" + ansible.builtin.command: "/usr/local/bin/nu -n -c 'nu-check /home/{{ item[0] }}/{{ nushell_config_path }}/{{ item[1] }}'" changed_when: false register: check_output failed_when: check_output.stdout != 'true' diff --git a/molecule/common/binary.yml b/molecule/common/binary.yml index 4c0757d..014c3ab 100644 --- a/molecule/common/binary.yml +++ b/molecule/common/binary.yml @@ -1,7 +1,7 @@ --- - name: Get nushell install path ansible.builtin.stat: - path: "{{ nushell_binary_path }}/nu" + path: "/usr/local/bin/nu" get_attributes: false get_checksum: false get_mime: false diff --git a/molecule/common/plugins.yml b/molecule/common/plugins.yml index 974f5b2..bff6a02 100644 --- a/molecule/common/plugins.yml +++ b/molecule/common/plugins.yml @@ -2,7 +2,7 @@ - name: Get list of registered plugins ansible.builtin.shell: # noqa command-instead-of-shell cmd: "version|get installed_plugins|split row ','|str trim|to json" - executable: "{{ nushell_binary_path }}/nu" + executable: "/usr/local/bin/nu" become_user: "{{ item }}" become: true register: installed_plugins diff --git a/molecule/common/profile.yml b/molecule/common/profile.yml index cb9337c..5206723 100644 --- a/molecule/common/profile.yml +++ b/molecule/common/profile.yml @@ -2,7 +2,7 @@ - name: Assert nu was not added to .profile ansible.builtin.lineinfile: path: "/home/{{ item }}/.profile" - line: "{{ nushell_binary_path }}/nu -l" + line: "/usr/local/bin/nu -l" state: absent check_mode: true register: profile diff --git a/molecule/common/shell.yml b/molecule/common/shell.yml index 106db5d..8f706c7 100644 --- a/molecule/common/shell.yml +++ b/molecule/common/shell.yml @@ -2,7 +2,7 @@ - name: Assert nushell is not added to /etc/shells ansible.builtin.lineinfile: path: /etc/shells - line: "{{ nushell_binary_path }}/nu" + line: "/usr/local/bin/nu" state: absent check_mode: yes register: shells @@ -18,7 +18,7 @@ - name: Assert nushell is not set as default shell of the user ansible.builtin.assert: - that: item.shell != "{{ nushell_binary_path }}/nu" + that: item.shell != "/usr/local/bin/nu" quiet: true loop: "{{ user_stats.results }}" loop_control: diff --git a/molecule/common/variant.yml b/molecule/common/variant.yml index 5e3b4f3..e438e8b 100644 --- a/molecule/common/variant.yml +++ b/molecule/common/variant.yml @@ -2,7 +2,7 @@ - name: Get list of features ansible.builtin.shell: # noqa command-instead-of-shell cmd: "version|get features" - executable: "{{ nushell_binary_path }}/nu" + executable: "/usr/local/bin/nu" become_user: "{{ item }}" become: true register: features diff --git a/molecule/default-shell/molecule.yml b/molecule/default-shell/molecule.yml index 91965c2..a19a306 100644 --- a/molecule/default-shell/molecule.yml +++ b/molecule/default-shell/molecule.yml @@ -6,7 +6,7 @@ driver: name: docker platforms: - name: instance - image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest" + image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest" command: "" volumes: - /sys/fs/cgroup:/sys/fs/cgroup:rw @@ -18,7 +18,7 @@ platforms: cgroupns_mode: host provisioner: name: ansible - log: false + log: true playbooks: prepare: ../common/prepare.yml verifier: diff --git a/molecule/default-shell/verify.yml b/molecule/default-shell/verify.yml index d858b72..fe68b18 100644 --- a/molecule/default-shell/verify.yml +++ b/molecule/default-shell/verify.yml @@ -29,7 +29,7 @@ - name: Assert nushell is set as default shell of users ansible.builtin.assert: - that: item.shell == "{{ nushell_binary_path }}/nu" + that: item.shell == "/usr/local/bin/nu" quiet: true loop: "{{ user_stats.results }}" loop_control: diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 91965c2..a19a306 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -6,7 +6,7 @@ driver: name: docker platforms: - name: instance - image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest" + image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest" command: "" volumes: - /sys/fs/cgroup:/sys/fs/cgroup:rw @@ -18,7 +18,7 @@ platforms: cgroupns_mode: host provisioner: name: ansible - log: false + log: true playbooks: prepare: ../common/prepare.yml verifier: diff --git a/molecule/full/converge.yml b/molecule/full/converge.yml deleted file mode 100644 index b1e8cd1..0000000 --- a/molecule/full/converge.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- name: Converge - hosts: all - vars: - nushell_variant: full - nu_users: - - ansible - tasks: - - name: "Include yethal.nushell" - ansible.builtin.include_role: - name: yethal.nushell diff --git a/molecule/full/molecule.yml b/molecule/full/molecule.yml deleted file mode 100644 index 91965c2..0000000 --- a/molecule/full/molecule.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -role_name_check: 1 -dependency: - name: galaxy -driver: - name: docker -platforms: - - name: instance - image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest" - command: "" - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:rw - tmpfs: - - /run - - /tmp - privileged: true - pre_build_image: true - cgroupns_mode: host -provisioner: - name: ansible - log: false - playbooks: - prepare: ../common/prepare.yml -verifier: - name: ansible diff --git a/molecule/full/verify.yml b/molecule/full/verify.yml deleted file mode 100644 index 9222583..0000000 --- a/molecule/full/verify.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -- name: Verify - hosts: all - vars_files: - - ../../vars/main.yml - vars: - nu_users: - - ansible - tasks: - - name: Include default assertions - ansible.builtin.include_tasks: "../common/{{ file }}.yml" - loop: - - binary - - configs - - plugins - - shell - - banner - - profile - loop_control: - loop_var: file - - - name: Get list of features - ansible.builtin.shell: # noqa command-instead-of-shell - cmd: "version|get features" - executable: "{{ nushell_binary_path }}/nu" - become_user: "{{ item }}" - become: true - register: features - changed_when: false - loop: "{{ nu_users }}" - - - name: Verify dataframes feature is present - ansible.builtin.assert: - that: "'dataframe' in item.stdout" - quiet: true - loop: "{{ features.results }}" - loop_control: - label: "{{ item.item }}" diff --git a/molecule/macos/molecule.yml b/molecule/macos/molecule.yml index b0f5771..8e20724 100644 --- a/molecule/macos/molecule.yml +++ b/molecule/macos/molecule.yml @@ -12,6 +12,6 @@ platforms: - name: instance provisioner: name: ansible - log: false + log: true verifier: name: ansible diff --git a/molecule/macos/verify.yml b/molecule/macos/verify.yml index 6fc232d..8e484a9 100644 --- a/molecule/macos/verify.yml +++ b/molecule/macos/verify.yml @@ -27,7 +27,7 @@ - name: Assert nushell is set as default shell of users ansible.builtin.assert: - that: item.shell == "{{ nushell_binary_path }}/nu" + that: item.shell == "/usr/local/bin/nu" quiet: true loop: "{{ user_stats.results }}" loop_control: @@ -36,7 +36,7 @@ - name: Assert nu was added to .zprofile ansible.builtin.lineinfile: path: "/home/{{ item }}/.zprofile" - line: "{{ nushell_binary_path }}/nu -l" + line: "/usr/local/bin/nu -l" state: present check_mode: true register: profile diff --git a/molecule/no-configs/molecule.yml b/molecule/no-configs/molecule.yml index 91965c2..a19a306 100644 --- a/molecule/no-configs/molecule.yml +++ b/molecule/no-configs/molecule.yml @@ -6,7 +6,7 @@ driver: name: docker platforms: - name: instance - image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest" + image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest" command: "" volumes: - /sys/fs/cgroup:/sys/fs/cgroup:rw @@ -18,7 +18,7 @@ platforms: cgroupns_mode: host provisioner: name: ansible - log: false + log: true playbooks: prepare: ../common/prepare.yml verifier: diff --git a/molecule/no-plugins/molecule.yml b/molecule/no-plugins/molecule.yml index 91965c2..a19a306 100644 --- a/molecule/no-plugins/molecule.yml +++ b/molecule/no-plugins/molecule.yml @@ -6,7 +6,7 @@ driver: name: docker platforms: - name: instance - image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest" + image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest" command: "" volumes: - /sys/fs/cgroup:/sys/fs/cgroup:rw @@ -18,7 +18,7 @@ platforms: cgroupns_mode: host provisioner: name: ansible - log: false + log: true playbooks: prepare: ../common/prepare.yml verifier: diff --git a/molecule/no-plugins/verify.yml b/molecule/no-plugins/verify.yml index 5bd9c65..986fc00 100644 --- a/molecule/no-plugins/verify.yml +++ b/molecule/no-plugins/verify.yml @@ -22,7 +22,7 @@ - name: Get list of registered plugins ansible.builtin.shell: # noqa command-instead-of-shell cmd: "version|to json" - executable: "{{ nushell_binary_path }}/nu" + executable: "/usr/local/bin/nu" become_user: "{{ item }}" become: true register: installed_plugins diff --git a/molecule/plugin-subset/molecule.yml b/molecule/plugin-subset/molecule.yml index 91965c2..a19a306 100644 --- a/molecule/plugin-subset/molecule.yml +++ b/molecule/plugin-subset/molecule.yml @@ -6,7 +6,7 @@ driver: name: docker platforms: - name: instance - image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest" + image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest" command: "" volumes: - /sys/fs/cgroup:/sys/fs/cgroup:rw @@ -18,7 +18,7 @@ platforms: cgroupns_mode: host provisioner: name: ansible - log: false + log: true playbooks: prepare: ../common/prepare.yml verifier: diff --git a/molecule/plugin-subset/verify.yml b/molecule/plugin-subset/verify.yml index 22ea350..15c5d4f 100644 --- a/molecule/plugin-subset/verify.yml +++ b/molecule/plugin-subset/verify.yml @@ -22,7 +22,7 @@ - name: Get list of registered plugins ansible.builtin.shell: # noqa command-instead-of-shell cmd: "version|get installed_plugins|split row ','|str trim|to json" - executable: "{{ nushell_binary_path }}/nu" + executable: "/usr/local/bin/nu" become: true become_user: "{{ item }}" register: installed_plugins diff --git a/molecule/profile/molecule.yml b/molecule/profile/molecule.yml index 91965c2..a19a306 100644 --- a/molecule/profile/molecule.yml +++ b/molecule/profile/molecule.yml @@ -6,7 +6,7 @@ driver: name: docker platforms: - name: instance - image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest" + image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest" command: "" volumes: - /sys/fs/cgroup:/sys/fs/cgroup:rw @@ -18,7 +18,7 @@ platforms: cgroupns_mode: host provisioner: name: ansible - log: false + log: true playbooks: prepare: ../common/prepare.yml verifier: diff --git a/molecule/profile/verify.yml b/molecule/profile/verify.yml index 9d2f671..c6e491d 100644 --- a/molecule/profile/verify.yml +++ b/molecule/profile/verify.yml @@ -23,7 +23,7 @@ - name: Assert nu was added to .profile ansible.builtin.lineinfile: path: "/home/{{ item }}/.profile" - line: "{{ nushell_binary_path }}/nu -l" + line: "/usr/local/bin/nu -l" state: present check_mode: true register: profile diff --git a/molecule/specific-version/molecule.yml b/molecule/specific-version/molecule.yml index 91965c2..a19a306 100644 --- a/molecule/specific-version/molecule.yml +++ b/molecule/specific-version/molecule.yml @@ -6,7 +6,7 @@ driver: name: docker platforms: - name: instance - image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest" + image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest" command: "" volumes: - /sys/fs/cgroup:/sys/fs/cgroup:rw @@ -18,7 +18,7 @@ platforms: cgroupns_mode: host provisioner: name: ansible - log: false + log: true playbooks: prepare: ../common/prepare.yml verifier: diff --git a/molecule/specific-version/verify.yml b/molecule/specific-version/verify.yml index e16fc30..2d4483b 100644 --- a/molecule/specific-version/verify.yml +++ b/molecule/specific-version/verify.yml @@ -24,7 +24,7 @@ - name: Get nushell version ansible.builtin.shell: # noqa command-instead-of-shell cmd: "version|get version" - executable: "{{ nushell_binary_path }}/nu" + executable: "/usr/local/bin/nu" register: version_to_check changed_when: false diff --git a/requirements.txt b/requirements.txt index 70ef28b..53eecd1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +requests==2.31.0 # https://github.com/ansible-community/molecule-plugins/issues/256 ansible yamllint ansible-lint diff --git a/tasks/configs.yml b/tasks/configs.yml index 4e2d541..40ebf20 100644 --- a/tasks/configs.yml +++ b/tasks/configs.yml @@ -133,7 +133,7 @@ ansible.builtin.lineinfile: path: "{{ item.homedir }}/{{ nushell_config_path }}/env.nu" regexp: "^.*PROMPT_INDICATOR.*$" - line: "{{ '$env.' if '0.83.0' is version(_nushell_version, '<=') else 'let-env ' }}PROMPT_INDICATOR = '({{ inventory_hostname }})〉'" + line: "{{ '$env.' if _nushell_version is version('0.83.0', '>=') else 'let-env ' }}PROMPT_INDICATOR = '({{ inventory_hostname }})〉'" validate: "{{ nushell_binary_path }}/nu -n -c 'source %s; $env'" when: add_hostname_to_prompt|bool loop: "{{ home_dirs }}" diff --git a/tasks/install.yml b/tasks/install.yml index b687c48..d109f77 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -13,9 +13,14 @@ ansible.builtin.set_fact: libc_flavor: "{{ 'gnu' if libc.stdout is version(min_glibc_version, '>=') else 'musl' }}" + +- name: Set package variant as fact + ansible.builtin.set_fact: + nu_plugins: "{{ nu_plugins if (_nushell_version is version('0.93.0', '>=')) else (nu_plugins | difference(['nu_plugin_polars'])) }}" + - name: Set package name as fact ansible.builtin.set_fact: - nushell_package: "nu-{{ _nushell_version }}-{{ arch_map[ansible_architecture] | default(ansible_architecture) }}-{{ package_map['linux'][libc_flavor][nushell_variant] if ansible_system == 'Linux' else package_map['darwin'][nushell_variant] }}" + nushell_package: "nu-{{ _nushell_version }}-{{ arch_map[ansible_architecture] | default(ansible_architecture) }}-{{ 'unknown-linux-' + libc_flavor if ansible_system == 'Linux' else 'apple-darwin' }}" - name: Extract package ansible.builtin.unarchive: diff --git a/tasks/main.yml b/tasks/main.yml index 91d590c..ebfaee1 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -21,20 +21,13 @@ register: installed changed_when: False - - name: Check installed nushell variant - ansible.builtin.command: - cmd: "{{ nushell_binary_path }}/nu -c 'version|get features'" - register: features - changed_when: false - - name: Set installed nushell version and variant as fact ansible.builtin.set_fact: installed_version: "{{ installed.stdout }}" - installed_variant: "{{ 'full' if 'dataframe' in features.stdout else 'default' }}" -- name: Install nushell version {{ _nushell_version + ' variant ' + nushell_variant }} +- name: Install nushell version {{ _nushell_version }} ansible.builtin.include_tasks: install.yml - when: (not nushell_status.stat.exists) or (_nushell_version != installed_version) or (nushell_variant != installed_variant) + when: (not nushell_status.stat.exists) or (_nushell_version != installed_version) register: install_status - name: Install nushell configs diff --git a/vars/main.yml b/vars/main.yml index 080787b..3b16df5 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,18 +1,7 @@ --- -nushell_binary_path: /usr/local/bin nushell_config_path: "{{ 'Library/Application Support/nushell' if ansible_system == 'Darwin' else '.config/nushell' }}" releases_endpoint: https://api.github.com/repos/nushell/nushell/releases +min_glibc_version: '2.29' arch_map: arm64: aarch64 armhf: armv7 -package_map: - linux: - musl: - default: unknown-linux-musl - full: linux-musl-full - gnu: - default: unknown-linux-gnu - full: linux-gnu-full - darwin: - default: apple-darwin - full: darwin-full