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

[2018.3] Merge forward from 2017.7 to 2018.3 #49896

Merged
merged 10 commits into from
Oct 4, 2018
2 changes: 1 addition & 1 deletion .ci/kitchen-ubuntu1604-py2
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ timeout(time: 6, unit: 'HOURS') {
} finally {
cleanWs notFailBuild: true
def currentResult = currentBuild.result ?: 'SUCCESS'
if ( currentResult == 'SUCCESS') {
if (currentResult == 'SUCCESS') {
githubNotify credentialsId: 'test-jenkins-credentials',
description: "The ${TEST_SUITE}-${TEST_PLATFORM} job has passed",
status: 'SUCCESS',
Expand Down
9 changes: 6 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ group :docker do
end

group :windows do
gem 'vagrant-wrapper'
gem 'kitchen-vagrant'
gem 'winrm', '~>2.0'
gem 'winrm-fs', '~>1.2.1'
gem 'winrm-fs', :git => 'https://github.com/dwoz/winrm-fs.git', :branch => 'chunked_downloads'
end

group :ec2 do
gem 'kitchen-ec2'
end

group :vagrant do
gem 'vagrant-wrapper'
gem 'kitchen-vagrant'
end
74 changes: 45 additions & 29 deletions salt/states/win_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,36 +166,46 @@ def hostname(name):
return ret


def join_domain(name, username=None, password=None, account_ou=None,
account_exists=False, restart=False):

def join_domain(name,
username=None,
password=None,
account_ou=None,
account_exists=False,
restart=False):
'''
Checks if a computer is joined to the Domain.
If the computer is not in the Domain, it will be joined.
Checks if a computer is joined to the Domain. If the computer is not in the
Domain, it will be joined.

Args:

name (str):
The name of the Domain.

name:
The name of the Domain.
username (str):
Username of an account which is authorized to join computers to the
specified domain. Need to be either fully qualified like
user@domain.tld or simply user.

username:
Username of an account which is authorized to join computers to the
specified domain. Need to be either fully qualified like user@domain.tld
or simply user.
password (str):
Password of the account to add the computer to the Domain.

password:
Password of the account to add the computer to the Domain.
account_ou (str):
The DN of the OU below which the account for this computer should be
created when joining the domain,
e.g. ou=computers,ou=departm_432,dc=my-company,dc=com.

account_ou:
The DN of the OU below which the account for this computer should be
created when joining the domain,
e.g. ou=computers,ou=departm_432,dc=my-company,dc=com.
account_exists (bool):
Needs to be set to ``True`` to allow re-using an existing computer
account.

account_exists:
Needs to be set to True to allow re-using an existing computer account.
restart (bool):
Needs to be set to ``True`` to restart the computer after a
successful join.

restart:
Needs to be set to True to restart the computer after a successful join.
Example:

.. code-block:: yaml

.. code-block::yaml
join_to_domain:
system.join_domain:
- name: mydomain.local.com
Expand All @@ -209,9 +219,6 @@ def join_domain(name, username=None, password=None, account_ou=None,
'result': True,
'comment': 'Computer already added to \'{0}\''.format(name)}

# Set name to domain, needed for the add to domain module.
domain = name

current_domain_dic = __salt__['system.get_domain_workgroup']()
if 'Domain' in current_domain_dic:
current_domain = current_domain_dic['Domain']
Expand All @@ -220,7 +227,7 @@ def join_domain(name, username=None, password=None, account_ou=None,
else:
current_domain = None

if domain == current_domain:
if name.lower() == current_domain.lower():
ret['comment'] = 'Computer already added to \'{0}\''.format(name)
return ret

Expand All @@ -229,11 +236,20 @@ def join_domain(name, username=None, password=None, account_ou=None,
ret['comment'] = 'Computer will be added to \'{0}\''.format(name)
return ret

result = __salt__['system.join_domain'](domain, username, password,
account_ou, account_exists,
restart)
result = __salt__['system.join_domain'](domain=name,
username=username,
password=password,
account_ou=account_ou,
account_exists=account_exists,
restart=restart)
if result is not False:
ret['comment'] = 'Computer added to \'{0}\''.format(name)
if restart:
ret['comment'] += '\nSystem will restart'
else:
ret['comment'] += '\nSystem needs to be restarted'
ret['changes'] = {'old': current_domain,
'new': name}
else:
ret['comment'] = 'Computer failed to join \'{0}\''.format(name)
ret['result'] = False
Expand Down