github.com/deemoprobe/k8s-first-commit@v0.0.0-20230430165612-a541f1982be3/src/templates/salt-master.sh (about)

     1  # Copyright 2014 Google Inc. All rights reserved.
     2  #
     3  # Licensed under the Apache License, Version 2.0 (the "License");
     4  # you may not use this file except in compliance with the License.
     5  # You may obtain a copy of the License at
     6  #
     7  #     http://www.apache.org/licenses/LICENSE-2.0
     8  #
     9  # Unless required by applicable law or agreed to in writing, software
    10  # distributed under the License is distributed on an "AS IS" BASIS,
    11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  # See the License for the specific language governing permissions and
    13  # limitations under the License.
    14  
    15  sed -i -e "\|^deb.*http://http.debian.net/debian| s/^/#/" /etc/apt/sources.list
    16  sed -i -e "\|^deb.*http://ftp.debian.org/debian| s/^/#/" /etc/apt/sources.list.d/backports.list
    17  
    18  # Prepopulate the name of the Master
    19  mkdir -p /etc/salt/minion.d
    20  echo "master: $MASTER_NAME" > /etc/salt/minion.d/master.conf
    21  
    22  cat <<EOF >/etc/salt/minion.d/grains.conf
    23  grains:
    24    roles:
    25      - kubernetes-master
    26  EOF
    27  
    28  # Auto accept all keys from minions that try to join
    29  mkdir -p /etc/salt/master.d
    30  cat <<EOF >/etc/salt/master.d/auto-accept.conf
    31  auto_accept: True
    32  EOF
    33  
    34  cat <<EOF >/etc/salt/master.d/reactor.conf
    35  # React to new minions starting by running highstate on them.
    36  reactor:
    37    - 'salt/minion/*/start':
    38      - /srv/reactor/start.sls
    39  EOF
    40  
    41  mkdir -p /srv/salt/nginx
    42  echo $MASTER_HTPASSWD > /srv/salt/nginx/htpasswd
    43  
    44  # Install Salt
    45  #
    46  # We specify -X to avoid a race condition that can cause minion failure to
    47  # install.  See https://github.com/saltstack/salt-bootstrap/issues/270
    48  #
    49  # -M installs the master
    50  curl -L http://bootstrap.saltstack.org | sh -s -- -M -X
    51  
    52  echo $MASTER_HTPASSWD > /srv/salt/nginx/htpasswd