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

visudo contains method not working properly. #74

Open
1 task
a-t-0 opened this issue Feb 14, 2022 · 0 comments
Open
1 task

visudo contains method not working properly. #74

a-t-0 opened this issue Feb 14, 2022 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed Optional

Comments

@a-t-0
Copy link
Member

a-t-0 commented Feb 14, 2022

Output:

Registering runner... succeeded                     runner=Q_1HebnF
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded! 
gitlab-runner ALL=(ALL) NOPASSWD: ALL
ERROR, did not find the visudo user thatwas added
Runtime platform                                    arch=amd64 os=linux pid=17862 revision=98daeee0 version=14.7.0
Runtime platform                                    arch=amd64 os=linux pid=17876 revision=98daeee0 version=14.7.0
The gitlab runner is already running
COMPLETED RUNNER INSTALLATION.

Related code:
https://github.com/Simple-Setup/Self-host-GitLab-Server-and-Runner-CI/blob/8fd9eb27ee794e4e61cfe376a0238cd8c926c245/src/install_and_boot_gitlab_runner.sh

	visudo_line="$RUNNER_USERNAME ALL=(ALL) NOPASSWD: ALL"
	filepath="/etc/sudoers"
	added_runner_to_visudo=$(visudo_contains "$visudo_line" "$filepath")
	if [  "$added_runner_to_visudo" == "NOTFOUND" ]; then
		echo "$RUNNER_USERNAME ALL=(ALL) NOPASSWD: ALL" | sudo EDITOR='tee -a' visudo
		added_runner_to_visudo=$(visudo_contains "$visudo_line" "$filepath")
		if [  "$added_runner_to_visudo" == "NOTFOUND" ]; then
			# TODO: raise exception
			echo "ERROR, did not find the visudo user thatwas added"
			#exit 1
		fi
	fi

Also has test:


@test "Test file contains string with variable username that does exist." {
	# TODO: Move this test to a function where the installation is completed.
	username="$GITLAB_SERVER_ACCOUNT_GLOBAL"
	line="$username	ALL=(ALL:ALL) ALL"
	actual_result=$(visudo_contains "$line" )
	EXPECTED_OUTPUT="FOUND"
		
	assert_equal "$actual_result" "$EXPECTED_OUTPUT"
}

in test/no_server_required/preserves_server/test_parsing.bats.

  • Resolve issue. (Ensure error message goes away because reason for error is removed.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed Optional
Projects
None yet
Development

No branches or pull requests

1 participant