Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mas - remove signed-in check from Mac OS 12.0+ #6519

Closed
1 task done
justinpjose opened this issue May 12, 2023 · 2 comments · Fixed by #6520
Closed
1 task done

mas - remove signed-in check from Mac OS 12.0+ #6519

justinpjose opened this issue May 12, 2023 · 2 comments · Fixed by #6520
Labels
feature This issue/PR relates to a feature request has_pr module module plugins plugin (any type)

Comments

@justinpjose
Copy link
Contributor

justinpjose commented May 12, 2023

Context

Unfortunately, as of Mac 12.0 and onwards, the mas account command isn't functioning correctly.
Issues have been already raised regarding this:

mas-cli/mas#417

Problem

The mas account is used as a check to see if the user is signed in before installing or upgrading an app using mas via Ansible.

As of Mac 12.0 and onwards, we cannot install or upgrade an app via mas via Ansible

Solution

Detailed in the Additional Information section

Issue Type

Feature Idea

Component Name

mas

Additional Information

Solution

In the check_signin function,

def check_signin(self):

We should do the following:

  1. Get the version of Mac OS running on your computer
import platform
mac_version = platform.mac_ver()
  1. Check if the version is greater than 12.0
def is_version_greater(version, reference_version):
    version_parts = [int(part) for part in version.split('.')]
    reference_parts = [int(part) for part in reference_version.split('.')]
    
    if version_parts > reference_parts:
        return True
    else:
        return False
  1. If it is greater, skip the logic defined in check_signin function and also print a user-friendly message to sign in via the Mac App Store GUI. Unfortunately, for the time being, this is the workaround mentioned in the issues.
def check_signin(self):
    ''' Verifies that the user is signed in to the Mac App Store '''
    
    # Only check this once per execution
    if self._checked_signin:
        return
    
    if self.is_version_greater(self._mac_version, WORKING_MAC_VERSION_MAS_ACCOUNT):
        print('WARNING: You must be signed in via the Mac App Store GUI else error will occur')
    else:
        rc, out, err = self.run(['account'])
        if out.split("\n", 1)[0].rstrip() == 'Not signed in':
            self.module.fail_json(msg='You must be signed in to the Mac App Store')

    self._checked_signin = True

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added feature This issue/PR relates to a feature request module module plugins plugin (any type) labels May 12, 2023
@justinpjose justinpjose changed the title general.community.mas - remove signed-in check from Mac OS 10.12+ general.community.mas - remove signed-in check from Mac OS 12.0+ May 12, 2023
@russoz russoz changed the title general.community.mas - remove signed-in check from Mac OS 12.0+ mas - remove signed-in check from Mac OS 12.0+ May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request has_pr module module plugins plugin (any type)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants