【问题标题】:ELASTICLUSTER How to generate a custom inventoryEASTICLUSTER 如何生成自定义库存
【发布时间】:2021-07-20 03:03:03
【问题描述】:

嘿伙计们,我找不到任何答案。所以我已经处理了elasticluster + AnsibleOpenStack,但我遇到了一些问题,其中一些问题我已经能够解决其中一些问题和其他一些问题不。我想分享一下我是如何解决库存问题的,因为它没有记录在任何地方。

我有这个配置文件,差不多来自官方documentation。在这一点上,一切都很好并且可以正常工作。但是,如果我们不想使用默认剧本怎么办。这很好,因为在文档中解释了如何通过添加 playbook_path=newPath 来更改该文件,但它开始抱怨变量、脚本,然后您必须将几乎所有内容从 EC 复制到您的自定义剧本。

另一个问题是库存文件。如果您检查我在这里拥有的这些配置,它有两个带有slurm_worker 的节点,那么在我的剧本中我可以使用它来执行我的任务,但是如果我想为其中一个节点运行一些角色怎么样?比如说connection_node ?.

# The cloud section defines all properties needed to connect to a specific cloud provider.
# You can define as many cloud sections you want, assuming you have access to different cloud providers and want to deploy different clusters in different clouds. The mapping between cluster and cloud provider is done in a cluster section

[cloud/openstack]
provider=openstack
build_timeout=600
identity_api_version=3
availability_zone=XXXXX


# This section contains information on how to access the instances started on the cloud, including the user and the SSH keys to use.
# Some of the values depend on the image you specified in the cluster section. Values defined here also can affect the setup section and the way the system is setup.
[login/userconfig]
image_user=username
image_sudo=True
image_user_sudo=xxxxxx
user_key_name=XXXXXX
user_key_private={path of the private key file}
user_key_public={path of the public key file}


# This section contain information on how to setup a cluster. After the cluster is started, elasticluster will run a setup provider in order to configure it.
# A setup section is mostly independent of any other, and can be easily re-used across multiple clouds and base OS images – that’s the whole point of ElastiCluster!

[setup/slurm]
provider=ansible
playbook_path=elasticluster/share/playbooks/slurm_cluster.yml
client_groups=slurm_client
master_groups=slurm_master
frontend_groups=slurm_worker
connection_groups=slurm_worker


## Updating elasticluster variables
global_var_ansible_python_interpreter=/usr/bin/python3
global_var_multiuser_cluster=yes
# Version of SLURM to install. Only used on RHEL/CentOS 7
global_var_slurm_version=20.02


# A cluster section defines a “template” for a cluster. This section has references to each one of the other sections and define the image to use, the default number of compute nodes and the security group.

[cluster/projectname]
cloud=openstack
flavor=m3.xsmall
login=userconfig
setup=slurm
image_id=xxxxxxxxxxxxxxxxxxxxxxx
network_ids=xxxxxxxxxxxxxxxxxxxxxxx
security_group=default
# Nodes
master_nodes=1
client_nodes=1
worker_nodes=2
connection_nodes=2
ssh_to=master

【问题讨论】:

    标签: docker ansible openstack


    【解决方案1】:

    在我的情况下,我需要不同的配置,因为这是我的逻辑,我需要安装一些不应该放在一个节点中的应用程序。

    解决自定义剧本的问题是用 docker 安装它。我所做的是复制main.yml 文件并删除我不需要的文件,然后将其作为卷挂载到docker 和我想要运行的自定义角色中。效果很好!!。

    默认情况下,Elasticluster 会创建一个包含组 slurm_worker, slurm_client & slurm_master 的库存文件,这是我的问题。如果我有更多的虚拟机,你想为每个虚拟机运行一些角色,怎么样?您必须使用slurm_worker,但该组中的某些主机您不想运行您的自定义角色。

    为了解决这个问题,我注意到当您运行 elasticluster setup 时,它将创建库存,因此可以修改它或创建您的自定义库存,如 here 所述,但我不喜欢这样不太对。

    我注意到 EC 中不存在的分布式剧本根据文档解释被忽略。然后,如果我在配置文件中添加新节点会发生什么,EC 会自动创建我的自定义库存文件,这很棒!!

    ....
    .
    .
    
    [setup/slurm]
    provider=ansible
    playbook_path=elasticluster/share/playbooks/slurm_cluster.yml
    client_groups=slurm_client,custom_client
    master_groups=slurm_master,custom_master
    frontend_groups=slurm_worker,custom_frontend
    connection_groups=slurm_worker,custom_connection
    
    .
    .
    ....
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-20
      • 1970-01-01
      • 1970-01-01
      • 2022-01-13
      • 2017-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多