Skip to content

Modified mssql_conf.py for SQL on Linux HA Ansible playbook#370

Merged
uc-msft merged 1 commit intomicrosoft:masterfrom
clayton006:master
Feb 23, 2018
Merged

Modified mssql_conf.py for SQL on Linux HA Ansible playbook#370
uc-msft merged 1 commit intomicrosoft:masterfrom
clayton006:master

Conversation

@clayton006
Copy link
Copy Markdown
Contributor

I modified the mssql_conf.py script by altering the detection logic for the /var/opt/mssql/mssql.conf file as this file is now created by default in SQL Server 2017 CU4 on Linux. Before CU4 this file was created after "/opt/mssql/bin/mssql-conf setup" was executed. The changes employ a regex to scan for the word "accepteula" as this would signify that the "/opt/mssql/bin/mssql-conf setup" has been executed successfully at one point.

I have tested these changes and the playbook now executes successfully.

msconfigfile.close()
if msconfigfileresult is None:
setup_env = os.environ.copy()
subprocess.check_call(
Copy link
Copy Markdown
Member

@arsing arsing Feb 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this common with the case below.

need_to_set_up = True

if os.path.isfile(...):
    if re.search(...) is not None:
        need_to_set_up = False

if need_to_set_up:
    subprocess.check_call(...)

if setup_sa_password is not None:
if os.path.isfile('/var/opt/mssql/mssql.conf'):
changed = False
msconfigfile = open('/var/opt/mssql/mssql.conf', 'r')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use with instead of manual close()

if setup_sa_password is not None:
if os.path.isfile('/var/opt/mssql/mssql.conf'):
changed = False
msconfigfile = open('/var/opt/mssql/mssql.conf', 'r')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mssql_conf_file

if os.path.isfile('/var/opt/mssql/mssql.conf'):
changed = False
msconfigfile = open('/var/opt/mssql/mssql.conf', 'r')
msconfigfiledata = msconfigfile.read()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mssql_conf_data

@clayton006
Copy link
Copy Markdown
Contributor Author

I'll review your feedback, make changes and re test.


changed = True

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is extra space here.

if os.path.isfile('/var/opt/mssql/mssql.conf'):
changed = False
else:
with open ("/var/opt/mssql/mssql.conf", "r") as mssql_conf_file:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove space between open and (

@arsing
Copy link
Copy Markdown
Member

arsing commented Feb 22, 2018

LGTM with the two whitespace issues fixed.

…s file is now created by default in SQL Server 2017 CU4 on Linux. Before CU4 this file was created after "/opt/mssql/bin/mssql-conf setup" was executed.
@uc-msft uc-msft merged commit ffe1dec into microsoft:master Feb 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants