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

Allow for more fine tune provisioning options #1807

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ Provisioning.DecodeCustomData=n
Provisioning.ExecuteCustomData=n
Provisioning.PasswordCryptId=6
Provisioning.PasswordCryptSaltLength=10
Provisioning.SetHostName=True
Provisioning.UserAccounts=True
ResourceDisk.Format=y
ResourceDisk.Filesystem=ext4
ResourceDisk.MountPoint=/mnt/resource
Expand Down Expand Up @@ -410,6 +412,20 @@ _Default: 10_

Length of random salt used when generating password hash.

#### __Provisioning.SetHostName__

_Type: Boolean_
_Default: y_

Control if WAAgent should attempt to set the VMs hostname
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain when this would be used? Perhaps add an example for when you would want to change from the default and not set the hostname.

Nit: periods at the end of the sentence for document consistency.


#### __Provisioning.UserAccounts

_Type: Boolean_
_Default: y_

Control if WAAgent should configure user accounts
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above. Maybe add an example usage when you wouldn't want to configure user accounts.

Nit: period at the end of the sentence for consistency.


#### __ResourceDisk.Format__

_Type: Boolean_
Expand Down
10 changes: 10 additions & 0 deletions azurelinuxagent/common/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def load_conf_from_file(conf_file_path, conf=__conf__):
"Provisioning.DecodeCustomData": False,
"Provisioning.ExecuteCustomData": False,
"Provisioning.MonitorHostName": False,
"Provisioning.SetHostName": True,
"Provisioning.UserAccounts": True,
"DetectScvmmEnv": False,
"ResourceDisk.Format": False,
"ResourceDisk.EnableSwap": False,
Expand Down Expand Up @@ -389,6 +391,14 @@ def get_monitor_hostname_period(conf=__conf__):
return conf.get_int("Provisioning.MonitorHostNamePeriod", 30)


def get_provisioning_hostname_set(conf=__conf__):
return conf.get_switch("Provisioning.SetHostName", True)


def get_provisioning_user_account_set(conf=__conf__):
return conf.get_switch("Provisioning.UserAccounts", True)


def get_httpproxy_host(conf=__conf__):
return conf.get("HttpProxy.Host", None)

Expand Down
15 changes: 9 additions & 6 deletions azurelinuxagent/pa/provision/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,16 @@ def handle_provision_guest_agent(self, provision_guest_agent):
def provision(self, ovfenv):
logger.info("Handle ovf-env.xml.")
try:
logger.info("Set hostname [{0}]".format(ovfenv.hostname))
self.osutil.set_hostname(ovfenv.hostname)

logger.info("Publish hostname [{0}]".format(ovfenv.hostname))
self.osutil.publish_hostname(ovfenv.hostname)
if conf.get_provisioning_hostname_set():
logger.info("Set hostname [{0}]".format(ovfenv.hostname))
self.osutil.set_hostname(ovfenv.hostname)

self.config_user_account(ovfenv)
logger.info("Publish hostname [{0}]".format(ovfenv.hostname))
self.osutil.publish_hostname(ovfenv.hostname)

if conf.get_provisioning_user_account_set():
self.config_user_account(ovfenv)

self.save_customdata(ovfenv)

Expand All @@ -233,7 +236,7 @@ def config_user_account(self, ovfenv):
self.osutil.chpasswd(ovfenv.username, ovfenv.user_password,
crypt_id=crypt_id, salt_len=salt_len)

logger.info("Configure sudoer")
logger.info("Configure sudoers")
self.osutil.conf_sudoer(ovfenv.username,
nopasswd=ovfenv.user_password is None)

Expand Down
6 changes: 6 additions & 0 deletions config/alpine/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Provisioning.DecodeCustomData=y
# Execute CustomData after provisioning.
Provisioning.ExecuteCustomData=y

# Set hostname of host by WAAgent on host provisioning.
Provisioning.SetHostName=y

# Allow WAAgent to provision useraccounts.
Provisioning.UserAccounts=y

# Format if unformatted. If 'n', resource disk will not be mounted.
ResourceDisk.Format=y

Expand Down
6 changes: 6 additions & 0 deletions config/arch/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Provisioning.DecodeCustomData=n
# Execute CustomData after provisioning.
Provisioning.ExecuteCustomData=n

# Set hostname of host by WAAgent on host provisioning.
Provisioning.SetHostName=y

# Allow WAAgent to provision useraccounts.
Provisioning.UserAccounts=y

# Algorithm used by crypt when generating password hash.
#Provisioning.PasswordCryptId=6

Expand Down
6 changes: 6 additions & 0 deletions config/clearlinux/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ Provisioning.DecodeCustomData=y
# Execute CustomData after provisioning.
Provisioning.ExecuteCustomData=n

# Set hostname of host by WAAgent on host provisioning.
Provisioning.SetHostName=y

# Allow WAAgent to provision useraccounts.
Provisioning.UserAccounts=y

# Allow reset password of sys user
Provisioning.AllowResetSysUser=n

Expand Down
6 changes: 6 additions & 0 deletions config/coreos/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Provisioning.DecodeCustomData=n
# Execute CustomData after provisioning.
Provisioning.ExecuteCustomData=n

# Set hostname of host by WAAgent on host provisioning.
Provisioning.SetHostName=y

# Allow WAAgent to provision useraccounts.
Provisioning.UserAccounts=y

# Algorithm used by crypt when generating password hash.
#Provisioning.PasswordCryptId=6

Expand Down
6 changes: 6 additions & 0 deletions config/debian/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Provisioning.DecodeCustomData=n
# Execute CustomData after provisioning.
Provisioning.ExecuteCustomData=n

# Set hostname of host by WAAgent on host provisioning.
Provisioning.SetHostName=y

# Allow WAAgent to provision useraccounts.
Provisioning.UserAccounts=y

# Algorithm used by crypt when generating password hash.
#Provisioning.PasswordCryptId=6

Expand Down
6 changes: 6 additions & 0 deletions config/gaia/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Provisioning.DecodeCustomData=y
# Execute CustomData after provisioning.
Provisioning.ExecuteCustomData=n

# Set hostname of host by WAAgent on host provisioning.
Provisioning.SetHostName=y

# Allow WAAgent to provision useraccounts.
Provisioning.UserAccounts=y

# Algorithm used by crypt when generating password hash.
Provisioning.PasswordCryptId=1

Expand Down
6 changes: 6 additions & 0 deletions config/iosxe/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Provisioning.DecodeCustomData=n
# Execute CustomData after provisioning.
Provisioning.ExecuteCustomData=n

# Set hostname of host by WAAgent on host provisioning.
Provisioning.SetHostName=y

# Allow WAAgent to provision useraccounts.
Provisioning.UserAccounts=y

# Algorithm used by crypt when generating password hash.
#Provisioning.PasswordCryptId=6

Expand Down
6 changes: 6 additions & 0 deletions config/nsbsd/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Provisioning.DecodeCustomData=n
# Execute CustomData after provisioning.
Provisioning.ExecuteCustomData=n

# Set hostname of host by WAAgent on host provisioning.
Provisioning.SetHostName=y

# Allow WAAgent to provision useraccounts.
Provisioning.UserAccounts=y

# Algorithm used by crypt when generating password hash.
#Provisioning.PasswordCryptId=6

Expand Down
6 changes: 6 additions & 0 deletions config/openbsd/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Provisioning.DecodeCustomData=n
# Execute CustomData after provisioning.
Provisioning.ExecuteCustomData=n

# Set hostname of host by WAAgent on host provisioning.
Provisioning.SetHostName=y

# Allow WAAgent to provision useraccounts.
Provisioning.UserAccounts=y

# Algorithm used by crypt when generating password hash.
#Provisioning.PasswordCryptId=6

Expand Down
6 changes: 6 additions & 0 deletions config/suse/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Provisioning.DecodeCustomData=n
# Execute CustomData after provisioning.
Provisioning.ExecuteCustomData=n

# Set hostname of host by WAAgent on host provisioning.
Provisioning.SetHostName=y

# Allow WAAgent to provision useraccounts.
Provisioning.UserAccounts=y

# Algorithm used by crypt when generating password hash.
#Provisioning.PasswordCryptId=6

Expand Down
6 changes: 6 additions & 0 deletions config/ubuntu/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Provisioning.DecodeCustomData=n
# Execute CustomData after provisioning.
Provisioning.ExecuteCustomData=n

# Set hostname of host by WAAgent on host provisioning.
Provisioning.SetHostName=y

# Allow WAAgent to provision useraccounts.
Provisioning.UserAccounts=y

# Algorithm used by crypt when generating password hash.
#Provisioning.PasswordCryptId=6

Expand Down
2 changes: 2 additions & 0 deletions tests/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
Provisioning.PasswordCryptSaltLength = 10
Provisioning.RegenerateSshHostKeyPair = True
Provisioning.SshHostKeyPairType = rsa
Provisioning.SetHostName = True
Provisioning.UserAccounts = True
ResourceDisk.EnableSwap = False
ResourceDisk.EnableSwapEncryption = False
ResourceDisk.Filesystem = ext4
Expand Down