File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/boto_elb.cpython-310.pyc
Back
o ;j[� � @ s� d Z ddlZddlZddlZddlZddlZddlZddlm Z e� e�Zdd� Z d(dd�Z d)d d�ZdZdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zd d!� Zd"d#� Zd)d$d%�Zd&d'� ZdS )*a< Manage ELBs .. versionadded:: 2014.7.0 Create and destroy ELBs. Be aware that this interacts with Amazon's services, and so may incur charges. This module uses ``boto``, which can be installed via package, or pip. This module accepts explicit elb credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no further configuration is necessary. More information available `here <http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html>`_. If IAM roles are not used you need to specify them either in a pillar file or in the minion's config file: .. code-block:: yaml elb.keyid: GKTADJGHEIQSXMKKRBJ08H elb.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs It's also possible to specify ``key``, ``keyid`` and ``region`` via a profile, either passed in as a dict, or as a string to pull from pillars or minion config: .. code-block:: yaml myprofile: keyid: GKTADJGHEIQSXMKKRBJ08H key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs region: us-east-1 .. code-block:: yaml Ensure myelb ELB exists: boto_elb.present: - name: myelb - region: us-east-1 - availability_zones: - us-east-1a - us-east-1c - us-east-1d - keyid: GKTADJGHEIQSXMKKRBJ08H - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs - listeners: - elb_port: 443 instance_port: 80 elb_protocol: HTTPS instance_protocol: HTTP certificate: 'arn:aws:iam::1111111:server-certificate/mycert' policies: - my-ssl-policy - cookie-policy - elb_port: 8210 instance_port: 8210 elb_protocol: TCP - backends: - instance_port: 80 policies: - enable-proxy-protocol - health_check: target: 'HTTP:80/' - attributes: cross_zone_load_balancing: enabled: true access_log: enabled: true s3_bucket_name: 'mybucket' s3_bucket_prefix: 'my-logs' emit_interval: 5 connecting_settings: idle_timeout: 60 - cnames: - name: mycname.example.com. zone: example.com. ttl: 60 - name: myothercname.example.com. zone: example.com. - security_groups: - my-security-group - policies: - policy_name: my-ssl-policy policy_type: SSLNegotiationPolicyType policy: Protocol-TLSv1.2: true Protocol-SSLv3: false Server-Defined-Cipher-Order: true ECDHE-ECDSA-AES128-GCM-SHA256: true - policy_name: cookie-policy policy_type: LBCookieStickinessPolicyType policy: {} # no policy means this is a session cookie - policy_name: enable-proxy-protocol policy_type: ProxyProtocolPolicyType policy: ProxyProtocol: true # Using a profile from pillars Ensure myelb ELB exists: boto_elb.present: - name: myelb - region: us-east-1 - profile: myelbprofile # Passing in a profile Ensure myelb ELB exists: boto_elb.present: - name: myelb - region: us-east-1 - profile: keyid: GKTADJGHEIQSXMKKRBJ08H key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs It's possible to specify attributes from pillars by specifying a pillar. You can override the values defined in the pillard by setting the attributes on the resource. The module will use the default pillar key 'boto_elb_attributes', which allows you to set default attributes for all ELB resources. Setting the attributes pillar: .. code-block:: yaml my_elb_attributes: cross_zone_load_balancing: enabled: true connection_draining: enabled: true timeout: 20 access_log: enabled: true s3_bucket_name: 'mybucket' s3_bucket_prefix: 'my-logs' emit_interval: 5 Overriding the attribute values on the resource: .. code-block:: yaml Ensure myelb ELB exists: boto_elb.present: - name: myelb - region: us-east-1 - attributes_from_pillar: my_elb_attributes # override cross_zone_load_balancing:enabled - attributes: cross_zone_load_balancing: enabled: false - profile: myelbprofile It's possible to specify cloudwatch alarms that will be setup along with the ELB. Note the alarm name will be defined by the name attribute provided, plus the ELB resource name. .. code-block:: yaml Ensure myelb ELB exists: boto_elb.present: - name: myelb - region: us-east-1 - profile: myelbprofile - alarms: UnHealthyHostCount: name: 'ELB UnHealthyHostCount **MANAGED BY SALT**' attributes: metric: UnHealthyHostCount namespace: AWS/ELB statistic: Average comparison: '>=' threshold: 1.0 period: 600 evaluation_periods: 6 unit: null description: ELB UnHealthyHostCount alarm_actions: ['arn:aws:sns:us-east-1:12345:myalarm'] insufficient_data_actions: [] ok_actions: ['arn:aws:sns:us-east-1:12345:myalarm'] You can also use alarms from pillars, and override values from the pillar alarms by setting overrides on the resource. Note that 'boto_elb_alarms' will be used as a default value for all resources, if defined and can be used to ensure alarms are always set for a resource. Setting the alarms in a pillar: .. code-block:: yaml my_elb_alarm: UnHealthyHostCount: name: 'ELB UnHealthyHostCount **MANAGED BY SALT**' attributes: metric: UnHealthyHostCount namespace: AWS/ELB statistic: Average comparison: '>=' threshold: 1.0 period: 600 evaluation_periods: 6 unit: null description: ELB UnHealthyHostCount alarm_actions: ['arn:aws:sns:us-east-1:12345:myalarm'] insufficient_data_actions: [] ok_actions: ['arn:aws:sns:us-east-1:12345:myalarm'] Overriding the alarm values on the resource: .. code-block:: yaml Ensure myelb ELB exists: boto_elb.present: - name: myelb - region: us-east-1 - profile: myelbprofile - alarms_from_pillar: my_elb_alarm # override UnHealthyHostCount:attributes:threshold - alarms: UnHealthyHostCount: attributes: threshold: 2.0 Tags can also be set: .. versionadded:: 2016.3.0 .. code-block:: yaml Ensure myelb ELB exists: boto_elb.present: - name: myelb - region: us-east-1 - profile: myelbprofile - tags: MyTag: 'My Tag Value' OtherTag: 'My Other Value' � N)�SaltInvocationErrorc C s dt v rdS dS )z) Only load if boto is available. �boto_elb.existsZboto_elb)Fz#boto_elb module could not be loaded)�__salt__� r r �H/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/boto_elb.py�__virtual__� s r �internet-facing�boto_elb_attributes�boto_elb_alarms�boto_elb_policiesTc $ C s@ t d | i �}|rtjj�||�n|}| ddi d�}t|tttd�f�s5d}t � |� |�|dd�� |S t|t�r?|�d �}t| ||||||||||�}|�|d d� |d |d g�d �� |d rh|d n|d |d<