Skip to content

Instantly share code, notes, and snippets.

@sierrezinal
Forked from c0psrul3/do_cloud-config.init.yaml
Created December 24, 2021 23:00
Show Gist options
  • Save sierrezinal/5e6ec1de8d82b969ca100f73bf7942ba to your computer and use it in GitHub Desktop.
Save sierrezinal/5e6ec1de8d82b969ca100f73bf7942ba to your computer and use it in GitHub Desktop.

Revisions

  1. MIke N revised this gist Jan 20, 2017. 1 changed file with 42 additions and 0 deletions.
    42 changes: 42 additions & 0 deletions do_cloud-config.init.yaml
    Original file line number Diff line number Diff line change
    @@ -134,3 +134,45 @@ runcmd:
    - sed -i -e '$aAllowUsers demo' /etc/ssh/sshd_config
    - restart ssh"}

    #Yet another way to update sshd_config
    #cloud-config
    users:
    - name: demo
    ssh-authorized-keys:
    - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCv60WjxoM39LgPDbiW7ne3gu18q0NIVv0RE6rDLNal1quXZ3nqAlANpl5qmhDQ+GS/sOtygSG4/9aiOA4vXO54k1mHWL2irjuB9XbXr00+44vSd2q/vtXdGXhdSMTf4/XK17fjKSG/9y3yD6nml6q9XgQxx9Vf/IkaKdlK0hbC1ds0+8h83PTb9dF3L7hf3Ch/ghvj5++tWJFdFeG+VI7EDuKNA4zL8C5FdYYWFA88YAmM8ndjA5qCjZXIIeZvZ/z9Kpy6DL0QZ8T3NsxRKapEU3nyiIuEAmn8fbnosWcsovw0IS1Hz6HsjYo4bu/gA82LWt3sdRUBZ/7ZsVD3ELip [email protected]
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    groups: sudo
    shell: /bin/bash
    write_files:
    - path: /etc/ssh/sshd_config
    content: |
    Port 4444
    Protocol 2
    HostKey /etc/ssh/ssh_host_rsa_key
    HostKey /etc/ssh/ssh_host_dsa_key
    HostKey /etc/ssh/ssh_host_ecdsa_key
    HostKey /etc/ssh/ssh_host_ed25519_key
    UsePrivilegeSeparation yes
    KeyRegenerationInterval 3600
    ServerKeyBits 1024
    SyslogFacility AUTH
    LogLevel INFO
    LoginGraceTime 120
    PermitRootLogin no
    StrictModes yes
    RSAAuthentication yes
    PubkeyAuthentication yes
    IgnoreRhosts yes
    RhostsRSAAuthentication no
    HostbasedAuthentication no
    PermitEmptyPasswords no
    ChallengeResponseAuthentication no
    X11Forwarding yes
    X11DisplayOffset 10
    PrintMotd no
    PrintLastLog yes
    TCPKeepAlive yes
    AcceptEnv LANG LC_*
    Subsystem sftp /usr/lib/openssh/sftp-server
    UsePAM yes
    AllowUsers demo
  2. MIke N revised this gist Jan 20, 2017. 1 changed file with 130 additions and 16 deletions.
    146 changes: 130 additions & 16 deletions do_cloud-config.init.yaml
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,136 @@
    #cloud-config script from [http://stackoverflow.com/questions/31214080/cloud-init-yaml-script-on-digital-ocean-droplets]
    #see also:
    # DO droplet metadata intro: [https://www.digitalocean.com/community/tutorials/an-introduction-to-droplet-metadata]
    # DO droplet metadata for DO-API: [https://www.digitalocean.com/community/tutorials/an-introduction-to-droplet-metadata#how-to-retrieve-droplet-metadata#digitalocean-api]
    # intro to cloud-config scripting: [https://www.digitalocean.com/community/tutorials/an-introduction-to-cloud-config-scripting]
    # howto: [https://www.digitalocean.com/community/tutorials/how-to-use-cloud-config-for-your-initial-server-setup]
    # coreos cloud-config docs: [https://coreos.com/os/docs/latest/cloud-config.html]
    # validator: [https://coreos.com/validate/]
    #
    #DO droplet metadata intro + for DO-API
    # [https://www.digitalocean.com/community/tutorials/an-introduction-to-droplet-metadata#how-to-retrieve-droplet-metadata#digitalocean-api]
    #
    #intro to cloud-config scripting (source of following examples)
    # [https://www.digitalocean.com/community/tutorials/an-introduction-to-cloud-config-scripting]
    #
    #howto
    # [https://www.digitalocean.com/community/tutorials/how-to-use-cloud-config-for-your-initial-server-setup]
    #
    #coreos cloud-config docs , validator
    # [https://coreos.com/os/docs/latest/cloud-config.html]
    # [https://coreos.com/validate/]
    #
    #see also examples directory inside Droplets
    # '/usr/share/doc/cloud-init/examples'

    #cloud-config
    write_files:
    - path: /test.txt
    content: |
    Here is a line.
    Another line is here.
    #cloud-config
    package_update: true


    #cloud-config
    package_upgrade: true


    #cloud-config
    packages:
    - package_1
    - package_2
    - [package_3, version_num]


    #cloud-config
    ssh_authorized_keys:
    - ssh_key_1
    - ssh_key_2


    #cloud-config
    manage-resolv-conf: true
    resolv_conf:
    nameservers:
    - 'first_nameserver'
    - 'second_nameserver'
    searchdomains:
    - first.domain.com
    - second.domain.com
    domain: domain.com
    options:
    option1: value1
    option2: value2
    option3: value3


    #cloud-config
    ssh_keys:
    rsa_private: |
    -----BEGIN RSA PRIVATE KEY-----
    your_rsa_private_key
    -----END RSA PRIVATE KEY-----
    rsa_public: your_rsa_public_key


    #cloud-config
    ca-certs:
    remove-defaults: true
    trusted:
    - |
    -----BEGIN CERTIFICATE-----
    your_CA_cert
    -----END CERTIFICATE-----
    #cloud-config
    runcmd:
    - [ sed, -i, -e, 's/here/there/g', some_file]
    - echo "modified some_file"
    - [cat, some_file]


    #cloud-config
    power_state:
    timeout: 120
    delay: "+5"
    message: Rebooting in five minutes. Please save your work.
    mode: reboot


    #---
    #real example: [http://stackoverflow.com/questions/31214080/cloud-init-yaml-script-on-digital-ocean-droplets]

    #cloud-config
    users:
    - name: username
    - name: demo
    ssh-authorized-keys:
    - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCv60WjxoM39LgPDbiW7ne3gu18q0NIVv0RE6rDLNal1quXZ3nqAlANpl5qmhDQ+GS/sOtygSG4/9aiOA4vXO54k1mHWL2irjuB9XbXr00+44vSd2q/vtXdGXhdSMTf4/XK17fjKSG/9y3yD6nml6 [email protected]
    - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPfb8aT/rawAUH7UBvjNRpg0ed7Jfvj7z0bELrmMhlRl [email protected]_ed25519
    - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ+qAaqs5wh0WTccouzoFi+X91xEuIIx/jkwwNGmPE3S [email protected]_ed25519
    - ssh-r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GGgOKh4tnqFfHQT6qhE2j/f/bu+GLKgvPS2Z3hxIMtV2umUvZ2fJMj2HwkdF+Vkr8h19fCW9NHNw4M5+jtozRp5Z4g9xQoHBh2FXQJlNWi6LVegwy0bW7W6OKMt86X9rqsN7s0WA+xYpFEJ9r03sDM8lHoJsrx3HVa2UPcPgmb5HKhVn4xqQJgMW2/D mnichols@gnstestpc04-1
    - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfRS0GQogb2UIAO65zMTZo/Bx2oXfvAi+oCSlwMgVyKjbZ/qQ+zaTUtP8G6G6Hwe79VhJNJYUp/uLZ6J/xmkYBoSgleV+5dhmjON4SqUk7sOG9JXvyDw02kV7cwG18Z/qh1TWrwZZJS1HqP6ZwwQhUSooSLCTy27CXEYtzdrDP+pxDEewIgMrPuw+oNONyNF9ygct12OD1TOS46PGbM/wANDBjF0P0uHLU1jr04J5iT9EgmgOZ/CpnojZbJMRgeXPt4LbshwG9GWSJdwzR3HV83CewV430hvhYvD92F7E/sql/7kf+4lQbkRkvgqZtvLQXbyw/2RBO75Qs/BR+fdGh mnichols@gnstestpc04-gh
    - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCv60WjxoM39LgPDbiW7ne3gu18q0NIVv0RE6rDLNal1quXZ3nqAlANpl5qmhDQ+GS/sOtygSG4/9aiOA4vXO54k1mHWL2irjuB9XbXr00+44vSd2q/vtXdGXhdSMTf4/XK17fjKSG/9y3yD6nml6q9XgQxx9Vf/IkaKdlK0hbC1ds0+8h83PTb9dF3L7hf3Ch/ghvj5++tWJFdFeG+VI7EDuKNA4zL8C5FdYYWFA88YAmM8ndjA5qCjZXIIeZvZ/z9Kpy6DL0QZ8T3NsxRKapEU3nyiIuEAmn8fbnosWcsovw0IS1Hz6HsjYo4bu/gA82LWt3sdRUBZ/7ZsVD3ELip [email protected]
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    groups: sudo
    shell: /bin/bash
    runcmd:
    - sed -i -e '/^Port/s/^.*$/Port 4444/' /etc/ssh/sshd_config
    - sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin no/' /etc/ssh/sshd_config
    - sed -i -e '$aAllowUsers demo' /etc/ssh/sshd_config
    - restart ssh


    #API version:
    {"name": "your_droplet_name",
    "private_networking": true,
    "region": "nyc3",
    "size": "512mb",
    "image": "ubuntu-14-04-x64",
    "user-data": "#cloud-config
    users:
    - name: demo
    ssh-authorized-keys:
    - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCv60WjxoM39LgPDbiW7ne3gu18q0NIVv0RE6rDLNal1quXZ3nqAlANpl5qmhDQ+GS/sOtygSG4/9aiOA4vXO54k1mHWL2irjuB9XbXr00+44vSd2q/vtXdGXhdSMTf4/XK17fjKSG/9y3yD6nml6q9XgQxx9Vf/IkaKdlK0hbC1ds0+8h83PTb9dF3L7hf3Ch/ghvj5++tWJFdFeG+VI7EDuKNA4zL8C5FdYYWFA88YAmM8ndjA5qCjZXIIeZvZ/z9Kpy6DL0QZ8T3NsxRKapEU3nyiIuEAmn8fbnosWcsovw0IS1Hz6HsjYo4bu/gA82LWt3sdRUBZ/7ZsVD3ELip [email protected]
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    groups: sudo
    shell: /bin/bash
    runcmd:
    - sed -i -e '/^Port/s/^.*$/Port 4444/' /etc/ssh/sshd_config
    - sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin no/' /etc/ssh/sshd_config
    - sed -i -e '$aAllowUsers demo' /etc/ssh/sshd_config
    - restart ssh"}

  3. MIke N revised this gist Jan 20, 2017. 1 changed file with 8 additions and 101 deletions.
    109 changes: 8 additions & 101 deletions do_cloud-config.init.yaml
    Original file line number Diff line number Diff line change
    @@ -1,104 +1,11 @@
    #
    #DO droplet metadata intro + for DO-API
    # [https://www.digitalocean.com/community/tutorials/an-introduction-to-droplet-metadata#how-to-retrieve-droplet-metadata#digitalocean-api]
    #
    #intro to cloud-config scripting (source of following examples)
    # [https://www.digitalocean.com/community/tutorials/an-introduction-to-cloud-config-scripting]
    #
    #howto
    # [https://www.digitalocean.com/community/tutorials/how-to-use-cloud-config-for-your-initial-server-setup]
    #
    #coreos cloud-config docs , validator
    # [https://coreos.com/os/docs/latest/cloud-config.html]
    # [https://coreos.com/validate/]
    #
    #see also examples directory inside Droplets
    # '/usr/share/doc/cloud-init/examples'

    #cloud-config
    write_files:
    - path: /test.txt
    content: |
    Here is a line.
    Another line is here.
    #cloud-config
    package_update: true


    #cloud-config
    package_upgrade: true


    #cloud-config
    packages:
    - package_1
    - package_2
    - [package_3, version_num]


    #cloud-config
    ssh_authorized_keys:
    - ssh_key_1
    - ssh_key_2


    #cloud-config
    manage-resolv-conf: true
    resolv_conf:
    nameservers:
    - 'first_nameserver'
    - 'second_nameserver'
    searchdomains:
    - first.domain.com
    - second.domain.com
    domain: domain.com
    options:
    option1: value1
    option2: value2
    option3: value3


    #cloud-config
    ssh_keys:
    rsa_private: |
    -----BEGIN RSA PRIVATE KEY-----
    your_rsa_private_key
    -----END RSA PRIVATE KEY-----
    rsa_public: your_rsa_public_key


    #cloud-config
    ca-certs:
    remove-defaults: true
    trusted:
    - |
    -----BEGIN CERTIFICATE-----
    your_CA_cert
    -----END CERTIFICATE-----
    #cloud-config
    runcmd:
    - [ sed, -i, -e, 's/here/there/g', some_file]
    - echo "modified some_file"
    - [cat, some_file]


    #cloud-config
    power_state:
    timeout: 120
    delay: "+5"
    message: Rebooting in five minutes. Please save your work.
    mode: reboot


    #---
    #real example: [http://stackoverflow.com/questions/31214080/cloud-init-yaml-script-on-digital-ocean-droplets]

    #cloud-config
    #cloud-config script from [http://stackoverflow.com/questions/31214080/cloud-init-yaml-script-on-digital-ocean-droplets]
    #see also:
    # DO droplet metadata intro: [https://www.digitalocean.com/community/tutorials/an-introduction-to-droplet-metadata]
    # DO droplet metadata for DO-API: [https://www.digitalocean.com/community/tutorials/an-introduction-to-droplet-metadata#how-to-retrieve-droplet-metadata#digitalocean-api]
    # intro to cloud-config scripting: [https://www.digitalocean.com/community/tutorials/an-introduction-to-cloud-config-scripting]
    # howto: [https://www.digitalocean.com/community/tutorials/how-to-use-cloud-config-for-your-initial-server-setup]
    # coreos cloud-config docs: [https://coreos.com/os/docs/latest/cloud-config.html]
    # validator: [https://coreos.com/validate/]
    users:
    - name: username
    ssh-authorized-keys:
  4. @c0psrul3 c0psrul3 revised this gist Jan 20, 2017. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion do_cloud-config.init.yaml
    Original file line number Diff line number Diff line change
    @@ -103,6 +103,13 @@ users:
    - name: username
    ssh-authorized-keys:
    - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCv60WjxoM39LgPDbiW7ne3gu18q0NIVv0RE6rDLNal1quXZ3nqAlANpl5qmhDQ+GS/sOtygSG4/9aiOA4vXO54k1mHWL2irjuB9XbXr00+44vSd2q/vtXdGXhdSMTf4/XK17fjKSG/9y3yD6nml6 [email protected]
    - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPfb8aT/rawAUH7UBvjNRpg0ed7Jfvj7z0bELrmMhlRl [email protected]_ed25519
    - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ+qAaqs5wh0WTccouzoFi+X91xEuIIx/jkwwNGmPE3S [email protected]_ed25519
    - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCaRyzjkVdfGUwkfwqF7ptNoEZhAeG8E6FmxWvV+5fJzuEJAduPCW3HxXD+DhHN0I7MxfMljdgsRVMcd2CLuMPJU/C0tjnQeTT7T9ME7EmKeko3GaSLhzw1T5k/Dkn9C6gVtChdIxfoyStoPz6mjBd+74q72FsVYnruIKDy+SGAC2cqWj3wfWfcX9B8AyZkb/UAQUsKDhmndl+YUVsccvu3Xo2XgbrnzWPCEZD9gZwSOyZiYXq9SRtz6f4PLXSJnUB38P2QctqjnSCHhsZwRJg/VpZjCieVQ0ILLGFv+US1/U2FFEtLN53GGcyw9d9UTwhhs7m6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sOG9JXvyDw02kV7cwG18Z/qh1TWrwZZJS1HqP6ZwwQhUSooSLCTy27CXEYtzdrDP+pxDEewIgMrPuw+oNONyNF9ygct12OD1TOS46PGbM/wANDBjF0P0uHLU1jr04J5iT9EgmgOZ/CpnojZbJMRgeXPt4LbshwG9GWSJdwzR3HV83CewV430hvhYvD92F7E/sql/7kf+4lQbkRkvgqZtvLQXbyw/2RBO75Qs/BR+fdGh mnichols@gnstestpc04-gh
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    groups: sudo
    shell: /bin/bash
    shell: /bin/bash
  5. @c0psrul3 c0psrul3 revised this gist Jan 20, 2017. 1 changed file with 101 additions and 8 deletions.
    109 changes: 101 additions & 8 deletions do_cloud-config.init.yaml
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,104 @@
    #cloud-config script from [http://stackoverflow.com/questions/31214080/cloud-init-yaml-script-on-digital-ocean-droplets]
    #see also:
    # DO droplet metadata intro: [https://www.digitalocean.com/community/tutorials/an-introduction-to-droplet-metadata]
    # DO droplet metadata for DO-API: [https://www.digitalocean.com/community/tutorials/an-introduction-to-droplet-metadata#how-to-retrieve-droplet-metadata#digitalocean-api]
    # intro to cloud-config scripting: [https://www.digitalocean.com/community/tutorials/an-introduction-to-cloud-config-scripting]
    # howto: [https://www.digitalocean.com/community/tutorials/how-to-use-cloud-config-for-your-initial-server-setup]
    # coreos cloud-config docs: [https://coreos.com/os/docs/latest/cloud-config.html]
    # validator: [https://coreos.com/validate/]
    #
    #DO droplet metadata intro + for DO-API
    # [https://www.digitalocean.com/community/tutorials/an-introduction-to-droplet-metadata#how-to-retrieve-droplet-metadata#digitalocean-api]
    #
    #intro to cloud-config scripting (source of following examples)
    # [https://www.digitalocean.com/community/tutorials/an-introduction-to-cloud-config-scripting]
    #
    #howto
    # [https://www.digitalocean.com/community/tutorials/how-to-use-cloud-config-for-your-initial-server-setup]
    #
    #coreos cloud-config docs , validator
    # [https://coreos.com/os/docs/latest/cloud-config.html]
    # [https://coreos.com/validate/]
    #
    #see also examples directory inside Droplets
    # '/usr/share/doc/cloud-init/examples'

    #cloud-config
    write_files:
    - path: /test.txt
    content: |
    Here is a line.
    Another line is here.
    #cloud-config
    package_update: true


    #cloud-config
    package_upgrade: true


    #cloud-config
    packages:
    - package_1
    - package_2
    - [package_3, version_num]


    #cloud-config
    ssh_authorized_keys:
    - ssh_key_1
    - ssh_key_2


    #cloud-config
    manage-resolv-conf: true
    resolv_conf:
    nameservers:
    - 'first_nameserver'
    - 'second_nameserver'
    searchdomains:
    - first.domain.com
    - second.domain.com
    domain: domain.com
    options:
    option1: value1
    option2: value2
    option3: value3


    #cloud-config
    ssh_keys:
    rsa_private: |
    -----BEGIN RSA PRIVATE KEY-----
    your_rsa_private_key
    -----END RSA PRIVATE KEY-----
    rsa_public: your_rsa_public_key


    #cloud-config
    ca-certs:
    remove-defaults: true
    trusted:
    - |
    -----BEGIN CERTIFICATE-----
    your_CA_cert
    -----END CERTIFICATE-----
    #cloud-config
    runcmd:
    - [ sed, -i, -e, 's/here/there/g', some_file]
    - echo "modified some_file"
    - [cat, some_file]


    #cloud-config
    power_state:
    timeout: 120
    delay: "+5"
    message: Rebooting in five minutes. Please save your work.
    mode: reboot


    #---
    #real example: [http://stackoverflow.com/questions/31214080/cloud-init-yaml-script-on-digital-ocean-droplets]

    #cloud-config
    users:
    - name: username
    ssh-authorized-keys:
  6. @c0psrul3 c0psrul3 created this gist Jan 20, 2017.
    15 changes: 15 additions & 0 deletions do_cloud-config.init.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #cloud-config script from [http://stackoverflow.com/questions/31214080/cloud-init-yaml-script-on-digital-ocean-droplets]
    #see also:
    # DO droplet metadata intro: [https://www.digitalocean.com/community/tutorials/an-introduction-to-droplet-metadata]
    # DO droplet metadata for DO-API: [https://www.digitalocean.com/community/tutorials/an-introduction-to-droplet-metadata#how-to-retrieve-droplet-metadata#digitalocean-api]
    # intro to cloud-config scripting: [https://www.digitalocean.com/community/tutorials/an-introduction-to-cloud-config-scripting]
    # howto: [https://www.digitalocean.com/community/tutorials/how-to-use-cloud-config-for-your-initial-server-setup]
    # coreos cloud-config docs: [https://coreos.com/os/docs/latest/cloud-config.html]
    # validator: [https://coreos.com/validate/]
    users:
    - name: username
    ssh-authorized-keys:
    - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCv60WjxoM39LgPDbiW7ne3gu18q0NIVv0RE6rDLNal1quXZ3nqAlANpl5qmhDQ+GS/sOtygSG4/9aiOA4vXO54k1mHWL2irjuB9XbXr00+44vSd2q/vtXdGXhdSMTf4/XK17fjKSG/9y3yD6nml6 [email protected]
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    groups: sudo
    shell: /bin/bash