From ed11bbadebe079586543a1e90cbe8f5bb045f99b Mon Sep 17 00:00:00 2001 From: Lennard Brinkhaus Date: Fri, 8 Sep 2023 18:45:59 +0200 Subject: [PATCH] initial comit --- .editorconfig | 19 +++++++++++++++++++ .gitignore | 20 +++++++++++++++++++ README.md | 38 +++++++++++++++++++++++++++++++++++++ ansible.cfg | 2 ++ defaults/main.yml | 4 ++++ meta/main.yml | 39 ++++++++++++++++++++++++++++++++++++++ tasks/install_rustup.yml | 20 +++++++++++++++++++ tasks/main.yml | 4 ++++ tasks/update_toolchain.yml | 9 +++++++++ tests/inventory | 1 + tests/test.yml | 5 +++++ 11 files changed, 161 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 README.md create mode 100644 ansible.cfg create mode 100644 defaults/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/install_rustup.yml create mode 100644 tasks/main.yml create mode 100644 tasks/update_toolchain.yml create mode 100644 tests/inventory create mode 100644 tests/test.yml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ab9fdb4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +# EditorConfig: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Defaults for all editor files +[*] +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +# Files with a smaller indent +[*.yml] +indent_size = 2 + +# Jinja2 template files +[*.j2] +end_of_line = lf \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ec2d6d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +local-configure.yml +.vagrant/ +docs/_build/ +roles/plone.plone_server +roles/jnv.unattended-upgrades +roles/tersmitten.fail2ban +roles/ANXS.hostname +roles/ANXS.apt +._* +bin/ +lib/ +include/ +local/ +tests.out +*.retry +*.log +vbox_host.cfg +.DS_Store +*.py[co] +.idea/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..79ff805 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +roles_path: ./../ \ No newline at end of file diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..928a576 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,4 @@ +--- +rust_version_check: true +rust_toolchain_version: "stable" +rustup_shell_script: "https://sh.rustup.rs" diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..3f381f1 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,39 @@ +galaxy_info: + author: Lennard Brinkhaus + description: Install and manage a Rust + company: DragSE + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + min_ansible_version: "2.1" + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + license: None + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + platforms: + - name: Debian + versions: + - all + - name: Ubuntu + versions: + - all + + galaxy_tags: + - rust + - cargo + - rustc + - rustup + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, +# if you add dependencies to this list. diff --git a/tasks/install_rustup.yml b/tasks/install_rustup.yml new file mode 100644 index 0000000..e119514 --- /dev/null +++ b/tasks/install_rustup.yml @@ -0,0 +1,20 @@ +- name: check if rustup is installed + shell: rustup check + register: rustup_exists + check_mode: false + changed_when: false + ignore_errors: true + +- block: + - name: Download rustup installer + get_url: + url: "{{ rustup_shell_script }}" + dest: /tmp/sh.rustup.rs + mode: '0755' + force: 'yes' + + - name: install rustup + shell: /tmp/sh.rustup.rs -y + + when: rustup_exists is failed + diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..df26152 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,4 @@ +--- +- include_tasks: install_rustup.yml + +- include_tasks: update_toolchain.yml diff --git a/tasks/update_toolchain.yml b/tasks/update_toolchain.yml new file mode 100644 index 0000000..7470fea --- /dev/null +++ b/tasks/update_toolchain.yml @@ -0,0 +1,9 @@ +- name: "get toolchain version" + shell: rustup check + register: old_toolchain_version + changed_when: false + +- name: "update toolchain and rustup" + register: update_toolchain + shell: "rustup update {{ rust_toolchain_version }}" + changed_when: "'downloading component' in update_toolchain.stdout" diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..ac96836 --- /dev/null +++ b/tests/inventory @@ -0,0 +1 @@ +192.168.1.142 diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..9937f9e --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: all + remote_user: root + roles: + - role-rust