Browse code

Remove ansible-galaxy login (#72288) (#72330)

* GitHub is removing the underlying API used to implement the `login` command. Since the general consensus seems to be that relatively nobody currently uses this command (in favor of explicit token passing), support was simply removed for interactive login. If a future need arises, this command should be reimplemented via OAuth Device Auth Grants.
* login or role login commands now produce a fatal error with a descriptive message

(cherry picked from commit 83909bfa22573777e3db5688773bda59721962ad)

Matt Davis authored on 2020/10/27 03:30:20
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,2 @@
0
+breaking_changes:
1
+- ansible-galaxy login command has been removed (see https://github.com/ansible/ansible/issues/71560)
... ...
@@ -555,28 +555,9 @@ class GalaxyCLI(CLI):
555 555
         """
556 556
         verify user's identify via GitHub and retrieve an auth token from Ansible Galaxy.
557 557
         """
558
-        # Authenticate with github and retrieve a token
559
-        if context.CLIARGS['token'] is None:
560
-            if C.GALAXY_TOKEN:
561
-                github_token = C.GALAXY_TOKEN
562
-            else:
563
-                login = GalaxyLogin(self.galaxy)
564
-                github_token = login.create_github_token()
565
-        else:
566
-            github_token = context.CLIARGS['token']
567
-
568
-        galaxy_response = self.api.authenticate(github_token)
569
-
570
-        if context.CLIARGS['token'] is None and C.GALAXY_TOKEN is None:
571
-            # Remove the token we created
572
-            login.remove_github_token()
573
-
574
-        # Store the Galaxy token
575
-        token = GalaxyToken()
576
-        token.set(galaxy_response['token'])
577
-
578
-        display.display("Successfully logged into Galaxy as %s" % galaxy_response['username'])
579
-        return 0
558
+        display.error("The login command was removed in late 2020. To continue importing roles to Galaxy, upgrade to "
559
+                      "ansible >= 2.9 or use the Web UI to import manually.")
560
+        return 1
580 561
 
581 562
     def execute_import(self):
582 563
         """ used to import a role into Ansible Galaxy """
... ...
@@ -1413,13 +1413,6 @@ GALAXY_SERVER:
1413 1413
   ini:
1414 1414
   - {key: server, section: galaxy}
1415 1415
   yaml: {key: galaxy.server}
1416
-GALAXY_TOKEN:
1417
-  default: null
1418
-  description: "GitHub personal access token"
1419
-  env: [{name: ANSIBLE_GALAXY_TOKEN}]
1420
-  ini:
1421
-  - {key: token, section: galaxy}
1422
-  yaml: {key: galaxy.token}
1423 1416
 HOST_KEY_CHECKING:
1424 1417
   name: Check host keys
1425 1418
   default: True