--- - hosts: localhost gather_facts: no vars: - some_version: 7.4.3 tasks: - name: Split using '.' ansible.builtin.debug: msg: "{{ some_version | split('.') }}" - name: Apply slice operator to the filter result, note the parenthesis. ansible.builtin.debug: msg: "{{ (some_version | split('.'))[0:2] }}" - name: Finaly join back the major and minor version numbers. ansible.builtin.debug: msg: "{{ (some_version | split('.'))[0:2] | join('.') }}"